diff options
author | Noel Grandin <noelgrandin@gmail.com> | 2022-04-21 21:09:07 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2022-04-22 13:27:56 +0200 |
commit | 9820f11ad2b1ef32e5527eec519b0a7c766e2602 (patch) | |
tree | 2ffa9a42bed16ab9a790d78b8f42a76996fdbe01 /unoidl | |
parent | e4d1731ba3e8bac2801d1b76cfb66bf7f9795468 (diff) |
address review comments on "use more string in unoidl.."
on
commit 2d9291b9433c9645b0870525211f74bfb1151555
Author: Noel Grandin <noel.grandin@collabora.co.uk>
Date: Thu Apr 21 12:53:15 2022 +0200
use more string_view in unoidl,codemaker
Primarily reverting the findEntity call-chain to use OUString
instead of std::u16string_view.
Change-Id: Ib01b9473c859bba3791563df753823bbf0a87ce0
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/133302
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'unoidl')
-rw-r--r-- | unoidl/source/legacyprovider.cxx | 5 | ||||
-rw-r--r-- | unoidl/source/legacyprovider.hxx | 2 | ||||
-rw-r--r-- | unoidl/source/sourcefileprovider.cxx | 5 | ||||
-rw-r--r-- | unoidl/source/sourcefileprovider.hxx | 2 | ||||
-rw-r--r-- | unoidl/source/sourcetreeprovider.cxx | 3 | ||||
-rw-r--r-- | unoidl/source/sourcetreeprovider.hxx | 2 | ||||
-rw-r--r-- | unoidl/source/unoidl-read.cxx | 2 | ||||
-rw-r--r-- | unoidl/source/unoidl-write.cxx | 2 | ||||
-rw-r--r-- | unoidl/source/unoidl.cxx | 7 | ||||
-rw-r--r-- | unoidl/source/unoidlprovider.cxx | 14 | ||||
-rw-r--r-- | unoidl/source/unoidlprovider.hxx | 2 |
11 files changed, 21 insertions, 25 deletions
diff --git a/unoidl/source/legacyprovider.cxx b/unoidl/source/legacyprovider.cxx index 577febd9c1b0..ab99fcf59dd1 100644 --- a/unoidl/source/legacyprovider.cxx +++ b/unoidl/source/legacyprovider.cxx @@ -813,12 +813,11 @@ rtl::Reference< MapCursor > LegacyProvider::createRootCursor() const { return new Cursor(&manager_, ucr_, ucr_); } -rtl::Reference< Entity > LegacyProvider::findEntity(std::u16string_view name) +rtl::Reference< Entity > LegacyProvider::findEntity(OUString const & name) const { - OUString s(name); return ucr_.isValid() - ? readEntity(&manager_, ucr_, ucr_, s.replace('.', '/'), true) + ? readEntity(&manager_, ucr_, ucr_, name.replace('.', '/'), true) : rtl::Reference< Entity >(); } diff --git a/unoidl/source/legacyprovider.hxx b/unoidl/source/legacyprovider.hxx index 8c22dbe0451c..caa1b38c84a4 100644 --- a/unoidl/source/legacyprovider.hxx +++ b/unoidl/source/legacyprovider.hxx @@ -26,7 +26,7 @@ public: virtual rtl::Reference< MapCursor > createRootCursor() const override; // throws FileFormatException: - virtual rtl::Reference< Entity > findEntity(std::u16string_view name) + virtual rtl::Reference< Entity > findEntity(OUString const & name) const override; private: diff --git a/unoidl/source/sourcefileprovider.cxx b/unoidl/source/sourcefileprovider.cxx index e487fcf47590..983b7d3c3403 100644 --- a/unoidl/source/sourcefileprovider.cxx +++ b/unoidl/source/sourcefileprovider.cxx @@ -15,7 +15,6 @@ #include "sourcefileprovider.hxx" #include "sourceprovider-scanner.hxx" -#include <o3tl/string_view.hxx> namespace unoidl::detail { @@ -106,12 +105,12 @@ rtl::Reference<MapCursor> SourceFileProvider::createRootCursor() const { return new Cursor(rootMap_); } -rtl::Reference<Entity> SourceFileProvider::findEntity(std::u16string_view name) +rtl::Reference<Entity> SourceFileProvider::findEntity(OUString const & name) const { std::map< OUString, rtl::Reference<Entity> > const * map = &rootMap_; for (sal_Int32 i = 0;;) { - OUString id(o3tl::getToken(name, 0, '.', i)); + OUString id(name.getToken(0, '.', i)); std::map< OUString, rtl::Reference<Entity> >::const_iterator j( map->find(id)); if (j == map->end()) { diff --git a/unoidl/source/sourcefileprovider.hxx b/unoidl/source/sourcefileprovider.hxx index 6e586294a0c4..52fd32f3c735 100644 --- a/unoidl/source/sourcefileprovider.hxx +++ b/unoidl/source/sourcefileprovider.hxx @@ -28,7 +28,7 @@ public: virtual rtl::Reference<MapCursor> createRootCursor() const override; // throws FileFormatException: - virtual rtl::Reference<Entity> findEntity(std::u16string_view name) const override; + virtual rtl::Reference<Entity> findEntity(OUString const& name) const override; private: virtual ~SourceFileProvider() noexcept override; diff --git a/unoidl/source/sourcetreeprovider.cxx b/unoidl/source/sourcetreeprovider.cxx index 2f115bef44bf..fea67405cd54 100644 --- a/unoidl/source/sourcetreeprovider.cxx +++ b/unoidl/source/sourcetreeprovider.cxx @@ -231,10 +231,9 @@ rtl::Reference<MapCursor> SourceTreeProvider::createRootCursor() const { return new Cursor(manager_, uri_); } -rtl::Reference<Entity> SourceTreeProvider::findEntity(std::u16string_view _name) +rtl::Reference<Entity> SourceTreeProvider::findEntity(OUString const & name) const { - OUString name(_name); std::map< OUString, rtl::Reference<Entity> >::iterator ci( cache_.find(name)); if (ci != cache_.end()) { diff --git a/unoidl/source/sourcetreeprovider.hxx b/unoidl/source/sourcetreeprovider.hxx index 9b2d6fd55cb9..37bd6baa1286 100644 --- a/unoidl/source/sourcetreeprovider.hxx +++ b/unoidl/source/sourcetreeprovider.hxx @@ -28,7 +28,7 @@ public: virtual rtl::Reference<MapCursor> createRootCursor() const override; // throws FileFormatException: - virtual rtl::Reference<Entity> findEntity(std::u16string_view name) const override; + virtual rtl::Reference<Entity> findEntity(OUString const& name) const override; private: virtual ~SourceTreeProvider() noexcept override; diff --git a/unoidl/source/unoidl-read.cxx b/unoidl/source/unoidl-read.cxx index 794bd0b473e7..706fe7f3d64c 100644 --- a/unoidl/source/unoidl-read.cxx +++ b/unoidl/source/unoidl-read.cxx @@ -103,7 +103,7 @@ std::u16string_view decomposeType( do { ++i; // skip '<' or ',' size_t j = i; - for (sal_Int32 level = 0; j != nucl.size(); ++j) { + for (size_t level = 0; j != nucl.size(); ++j) { sal_Unicode c = nucl[j]; if (c == ',') { if (level == 0) { diff --git a/unoidl/source/unoidl-write.cxx b/unoidl/source/unoidl-write.cxx index dafca970c246..5ddd98468359 100644 --- a/unoidl/source/unoidl-write.cxx +++ b/unoidl/source/unoidl-write.cxx @@ -394,7 +394,7 @@ void mapEntities( std::map< OUString, Item >::iterator k(map2->find(id)); if (k == map2->end()) { rtl::Reference< unoidl::Entity > ent2( - manager->findEntity(t.subView(0, j - 1))); + manager->findEntity(t.copy(0, j - 1))); assert(ent2.is()); k = map2->insert(std::make_pair(id, Item(ent2))).first; } diff --git a/unoidl/source/unoidl.cxx b/unoidl/source/unoidl.cxx index 5dfce2348d0c..749f9afe4f25 100644 --- a/unoidl/source/unoidl.cxx +++ b/unoidl/source/unoidl.cxx @@ -164,7 +164,7 @@ ServiceBasedSingletonEntity::~ServiceBasedSingletonEntity() noexcept {} Provider::~Provider() noexcept {} -rtl::Reference< Provider > Manager::addProvider(std::u16string_view uri) { +rtl::Reference< Provider > Manager::addProvider(OUString const & uri) { rtl::Reference< Provider > p(loadProvider(uri)); assert(p.is()); { @@ -174,7 +174,7 @@ rtl::Reference< Provider > Manager::addProvider(std::u16string_view uri) { return p; } -rtl::Reference< Entity > Manager::findEntity(std::u16string_view name) const { +rtl::Reference< Entity > Manager::findEntity(OUString const & name) const { //TODO: caching? (here or in cppuhelper::TypeManager?) osl::MutexGuard g(mutex_); for (auto & i: providers_) { @@ -194,8 +194,7 @@ rtl::Reference< MapCursor > Manager::createCursor(OUString const & name) Manager::~Manager() noexcept {} -rtl::Reference< Provider > Manager::loadProvider(std::u16string_view _uri) { - OUString uri(_uri); +rtl::Reference< Provider > Manager::loadProvider(OUString const & uri) { osl::DirectoryItem item; if (osl::DirectoryItem::get(uri, item) == osl::FileBase::E_None) { osl::FileStatus status(osl_FileStatus_Mask_Type); diff --git a/unoidl/source/unoidlprovider.cxx b/unoidl/source/unoidlprovider.cxx index de158f10b1b2..0b29906a8cb2 100644 --- a/unoidl/source/unoidlprovider.cxx +++ b/unoidl/source/unoidlprovider.cxx @@ -16,6 +16,7 @@ #include <string_view> #include <vector> +#include <o3tl/string_view.hxx> #include <osl/endian.h> #include <osl/file.h> #include <rtl/character.hxx> @@ -27,7 +28,6 @@ #include <sal/types.h> #include <salhelper/simplereferenceobject.hxx> #include <unoidl/unoidl.hxx> -#include <o3tl/string_view.hxx> #include "unoidlprovider.hxx" @@ -508,7 +508,7 @@ Compare compare( sal_uInt32 findInMap( rtl::Reference< MappedFile > const & file, MapEntry const * mapBegin, - sal_uInt32 mapSize, std::u16string_view name, sal_Int32 nameOffset, + sal_uInt32 mapSize, OUString const & name, sal_Int32 nameOffset, sal_Int32 nameLength) { if (mapSize == 0) { @@ -1349,21 +1349,21 @@ rtl::Reference< MapCursor > UnoidlProvider::createRootCursor() const { rtl::Reference<UnoidlModuleEntity>(), map_); } -rtl::Reference< Entity > UnoidlProvider::findEntity(std::u16string_view name) const +rtl::Reference< Entity > UnoidlProvider::findEntity(OUString const & name) const { NestedMap map(map_); bool cgroup = false; for (sal_Int32 i = 0;;) { - size_t j = name.find('.', i); - if (j == std::u16string_view::npos) { - j = name.size(); + sal_Int32 j = name.indexOf('.', i); + if (j == -1) { + j = name.getLength(); } sal_Int32 off = findInMap( file_, map.map.begin, map.map.size, name, i, j - i); if (off == 0) { return rtl::Reference< Entity >(); } - if (j == name.size()) { + if (j == name.getLength()) { return cgroup ? rtl::Reference< Entity >() : readEntity(file_, off, std::set(map.trace)); diff --git a/unoidl/source/unoidlprovider.hxx b/unoidl/source/unoidlprovider.hxx index 244bd26f3513..734f8592b814 100644 --- a/unoidl/source/unoidlprovider.hxx +++ b/unoidl/source/unoidlprovider.hxx @@ -41,7 +41,7 @@ public: virtual rtl::Reference< MapCursor > createRootCursor() const override; // throws FileFormatException: - virtual rtl::Reference< Entity > findEntity(std::u16string_view name) + virtual rtl::Reference< Entity > findEntity(OUString const & name) const override; private: |