summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2022-05-06 16:00:02 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2022-05-06 20:55:43 +0200
commit738b8f09c52a0e0234842c622786fccbb027621b (patch)
tree95f45a8c337f16be41a14602386d3340043da795
parent517e07bbcf668e1ea58dabeb35c0fb467b36ed05 (diff)
remove unnecessary sequenceToContainer
If we are not going to manipulate the resulting vector, then it is actually slower, since we have to allocate more storage for the vector Change-Id: I6d5f5b0150cea9e8a0663ccb1398b0237f3fca9a Reviewed-on: https://gerrit.libreoffice.org/c/core/+/133943 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
-rw-r--r--filter/source/config/cache/cacheitem.cxx8
-rw-r--r--filter/source/config/cache/filtercache.cxx10
-rw-r--r--filter/source/config/cache/filterfactory.cxx7
-rw-r--r--filter/source/config/cache/filterfactory.hxx2
-rw-r--r--filter/source/config/cache/typedetection.cxx4
5 files changed, 15 insertions, 16 deletions
diff --git a/filter/source/config/cache/cacheitem.cxx b/filter/source/config/cache/cacheitem.cxx
index a406b16ff130..0814e7c49733 100644
--- a/filter/source/config/cache/cacheitem.cxx
+++ b/filter/source/config/cache/cacheitem.cxx
@@ -198,12 +198,12 @@ static bool isSubSet(const css::uno::Any& aSubSet,
(aSet >>= uno_s2)
)
{
- std::vector<OUString> stl_s1(comphelper::sequenceToContainer< std::vector<OUString> >(uno_s1));
- std::vector<OUString> stl_s2(comphelper::sequenceToContainer< std::vector<OUString> >(uno_s2));
+ auto s2Begin = uno_s2.getConstArray();
+ auto s2End = uno_s2.getConstArray() + uno_s2.getLength();
- for (auto const& elem : stl_s1)
+ for (auto const& elem : uno_s1)
{
- if (::std::find(stl_s2.begin(), stl_s2.end(), elem) == stl_s2.end())
+ if (::std::find(s2Begin, s2End, elem) == s2End)
{
return false;
}
diff --git a/filter/source/config/cache/filtercache.cxx b/filter/source/config/cache/filtercache.cxx
index 052a7d566eee..f7ce4467a56d 100644
--- a/filter/source/config/cache/filtercache.cxx
+++ b/filter/source/config/cache/filtercache.cxx
@@ -1177,7 +1177,7 @@ void FilterCache::impl_validateAndOptimize()
CacheItem& rLoader = frameLoader.second;
css::uno::Any& rTypesReg = rLoader[PROPNAME_TYPES];
- std::vector<OUString> lTypesReg (comphelper::sequenceToContainer< std::vector<OUString> >(rTypesReg.get<css::uno::Sequence<OUString> >()));
+ const css::uno::Sequence<OUString> lTypesReg = rTypesReg.get<css::uno::Sequence<OUString> >();
for (auto const& typeReg : lTypesReg)
{
@@ -2170,8 +2170,8 @@ OUString FilterCache::impl_searchFrameLoaderForType(const OUString& sType) const
{
const OUString& sItem = frameLoader.first;
::comphelper::SequenceAsHashMap lProps(frameLoader.second);
- std::vector<OUString> lTypes(
- comphelper::sequenceToContainer< std::vector<OUString> >(lProps[PROPNAME_TYPES].get<css::uno::Sequence<OUString> >()));
+ const css::uno::Sequence<OUString> lTypes =
+ lProps[PROPNAME_TYPES].get<css::uno::Sequence<OUString> >();
if (::std::find(lTypes.begin(), lTypes.end(), sType) != lTypes.end())
return sItem;
@@ -2187,8 +2187,8 @@ OUString FilterCache::impl_searchContentHandlerForType(const OUString& sType) co
{
const OUString& sItem = contentHandler.first;
::comphelper::SequenceAsHashMap lProps(contentHandler.second);
- std::vector<OUString> lTypes(
- comphelper::sequenceToContainer< std::vector<OUString> >( lProps[PROPNAME_TYPES].get<css::uno::Sequence<OUString> >() ));
+ const css::uno::Sequence<OUString> lTypes =
+ lProps[PROPNAME_TYPES].get<css::uno::Sequence<OUString> >();
if (::std::find(lTypes.begin(), lTypes.end(), sType) != lTypes.end())
return sItem;
}
diff --git a/filter/source/config/cache/filterfactory.cxx b/filter/source/config/cache/filterfactory.cxx
index 33d1b44ae4b2..d98b2f3174e7 100644
--- a/filter/source/config/cache/filterfactory.cxx
+++ b/filter/source/config/cache/filterfactory.cxx
@@ -391,7 +391,7 @@ std::vector<OUString> FilterFactory::impl_getSortedFilterList(const QueryTokeniz
{
// more complex search for all filters
// We check first, which office modules are installed...
- std::vector<OUString> lModules = impl_getListOfInstalledModules();
+ const css::uno::Sequence<OUString> lModules = impl_getListOfInstalledModules();
for (auto const& module : lModules)
{
std::vector<OUString> lFilters4Module = impl_getSortedFilterListForModule(module, nIFlags, nEFlags);
@@ -406,11 +406,10 @@ std::vector<OUString> FilterFactory::impl_getSortedFilterList(const QueryTokeniz
}
-std::vector<OUString> FilterFactory::impl_getListOfInstalledModules()
+css::uno::Sequence<OUString> FilterFactory::impl_getListOfInstalledModules()
{
css::uno::Reference< css::container::XNameAccess > xModuleConfig = officecfg::Setup::Office::Factories::get();
- std::vector<OUString> lModules(comphelper::sequenceToContainer< std::vector<OUString> >(xModuleConfig->getElementNames()));
- return lModules;
+ return xModuleConfig->getElementNames();
}
diff --git a/filter/source/config/cache/filterfactory.hxx b/filter/source/config/cache/filterfactory.hxx
index f4c161df2914..9be370f4dc56 100644
--- a/filter/source/config/cache/filterfactory.hxx
+++ b/filter/source/config/cache/filterfactory.hxx
@@ -95,7 +95,7 @@ class FilterFactory : public ::cppu::ImplInheritanceHelper< BaseContainer
/** TODO document me
*/
- static std::vector<OUString> impl_getListOfInstalledModules();
+ static css::uno::Sequence<OUString> impl_getListOfInstalledModules();
/** @short implement the container string query:
diff --git a/filter/source/config/cache/typedetection.cxx b/filter/source/config/cache/typedetection.cxx
index 44c4c9029641..8ea578f7161a 100644
--- a/filter/source/config/cache/typedetection.cxx
+++ b/filter/source/config/cache/typedetection.cxx
@@ -671,8 +671,8 @@ bool TypeDetection::impl_getPreselectionForType(
// otherwise we must know, if it matches to the given URL really.
// especially if it matches by its extension or pattern registration.
- std::vector<OUString> lExtensions(comphelper::sequenceToContainer< std::vector<OUString> >(aType[PROPNAME_EXTENSIONS].get<css::uno::Sequence<OUString> >() ));
- std::vector<OUString> lURLPattern(comphelper::sequenceToContainer< std::vector<OUString> >(aType[PROPNAME_URLPATTERN].get<css::uno::Sequence<OUString> >() ));
+ const css::uno::Sequence<OUString> lExtensions = aType[PROPNAME_EXTENSIONS].get<css::uno::Sequence<OUString> >();
+ const css::uno::Sequence<OUString> lURLPattern = aType[PROPNAME_URLPATTERN].get<css::uno::Sequence<OUString> >();
for (auto const& extension : lExtensions)
{