summaryrefslogtreecommitdiff
path: root/filter/source/config
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2022-05-23 11:26:07 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2022-05-23 18:48:42 +0200
commit41bbc62f38b9eac97c03dc5a7e706fa6aaff055c (patch)
tree64eaed0a7834bd891d3784dcfc8426acb5f5a44c /filter/source/config
parent86c95d195dfb1af7511cc0e70a93de9813284855 (diff)
elide allocation of CacheItem when enumerating filters
Change-Id: I44f83485b984548118364dc58cbc3939001506d4 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/134805 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'filter/source/config')
-rw-r--r--filter/source/config/cache/basecontainer.cxx6
-rw-r--r--filter/source/config/cache/cacheitem.cxx12
-rw-r--r--filter/source/config/cache/cacheitem.hxx6
-rw-r--r--filter/source/config/cache/filtercache.cxx4
-rw-r--r--filter/source/config/cache/filtercache.hxx6
-rw-r--r--filter/source/config/cache/filterfactory.cxx10
-rw-r--r--filter/source/config/cache/typedetection.cxx14
7 files changed, 26 insertions, 32 deletions
diff --git a/filter/source/config/cache/basecontainer.cxx b/filter/source/config/cache/basecontainer.cxx
index 6f9491eeaac1..c5c9ff939443 100644
--- a/filter/source/config/cache/basecontainer.cxx
+++ b/filter/source/config/cache/basecontainer.cxx
@@ -362,14 +362,10 @@ css::uno::Reference< css::container::XEnumeration > SAL_CALL BaseContainer::crea
try
{
- // convert the given properties first to our internal representation
- CacheItem lProps;
- lProps << lProperties;
-
// search the key names of all items, where its properties match
// the given ones in its minimum
FilterCache* pCache = impl_getWorkingCache();
- lKeys = pCache->getMatchingItemsByProps(m_eType, lProps);
+ lKeys = pCache->getMatchingItemsByProps(m_eType, o3tl::span<const css::beans::NamedValue>( lProperties.getConstArray(), lProperties.getLength() ));
}
catch(const css::uno::Exception&)
{
diff --git a/filter/source/config/cache/cacheitem.cxx b/filter/source/config/cache/cacheitem.cxx
index dc28b5471d55..595d3891aa7d 100644
--- a/filter/source/config/cache/cacheitem.cxx
+++ b/filter/source/config/cache/cacheitem.cxx
@@ -263,19 +263,19 @@ static bool isSubSet(const css::uno::Any& aSubSet,
}
-bool CacheItem::haveProps(const CacheItem& lProps) const
+bool CacheItem::haveProps(o3tl::span< const css::beans::NamedValue > lProps) const
{
for (auto const& prop : lProps)
{
// i) one required property does not exist at this item => return false
- const_iterator pItThis = find(prop.first);
+ const_iterator pItThis = find(prop.Name);
if (pItThis == end())
{
return false;
}
// ii) one item does not have the right value => return false
- if (!isSubSet(prop.second, pItThis->second))
+ if (!isSubSet(prop.Value, pItThis->second))
{
return false;
}
@@ -288,7 +288,7 @@ bool CacheItem::haveProps(const CacheItem& lProps) const
}
-bool CacheItem::dontHaveProps(const CacheItem& lProps) const
+bool CacheItem::dontHaveProps(o3tl::span< const css::beans::NamedValue > lProps) const
{
for (auto const& prop : lProps)
{
@@ -296,7 +296,7 @@ bool CacheItem::dontHaveProps(const CacheItem& lProps) const
// => continue with next one, because
// "excluding" means... "don't have it".
// And "not exists" matches to "don't have it".
- const_iterator pItThis = find(prop.first);
+ const_iterator pItThis = find(prop.Name);
if (pItThis == end())
{
continue;
@@ -305,7 +305,7 @@ bool CacheItem::dontHaveProps(const CacheItem& lProps) const
// ii) one item have the right value => return false
// because this item has the requested property...
// But we checked for "don't have it" here.
- if (isSubSet(prop.second, pItThis->second))
+ if (isSubSet(prop.Value, pItThis->second))
{
return false;
}
diff --git a/filter/source/config/cache/cacheitem.hxx b/filter/source/config/cache/cacheitem.hxx
index 965bf7a40126..b20bf72c805c 100644
--- a/filter/source/config/cache/cacheitem.hxx
+++ b/filter/source/config/cache/cacheitem.hxx
@@ -24,7 +24,7 @@
#include <com/sun/star/beans/PropertyValue.hpp>
#include <vector>
#include <comphelper/sequenceashashmap.hxx>
-
+#include <o3tl/span.hxx>
namespace filter::config {
@@ -74,7 +74,7 @@ class CacheItem : public ::comphelper::SequenceAsHashMap
@return sal_True if all given properties exists
at this item; sal_False otherwise.
*/
- bool haveProps(const CacheItem& lProps) const;
+ bool haveProps(o3tl::span< const css::beans::NamedValue > lProps) const;
/** @short check, if the given properties don't exist
@@ -90,7 +90,7 @@ class CacheItem : public ::comphelper::SequenceAsHashMap
@return sal_False if at least on property exists at this item(!);
sal_True otherwise.
*/
- bool dontHaveProps(const CacheItem& lProps) const;
+ bool dontHaveProps(o3tl::span< const css::beans::NamedValue > lProps) const;
/** @short because we know two UIName properties
diff --git a/filter/source/config/cache/filtercache.cxx b/filter/source/config/cache/filtercache.cxx
index ec995700a366..b32586162146 100644
--- a/filter/source/config/cache/filtercache.cxx
+++ b/filter/source/config/cache/filtercache.cxx
@@ -245,8 +245,8 @@ bool FilterCache::isFillState(FilterCache::EFillState eState) const
std::vector<OUString> FilterCache::getMatchingItemsByProps( EItemType eType ,
- const CacheItem& lIProps,
- const CacheItem& lEProps) const
+ o3tl::span< const css::beans::NamedValue > lIProps,
+ o3tl::span< const css::beans::NamedValue > lEProps) const
{
// SAFE ->
osl::MutexGuard aLock(m_aMutex);
diff --git a/filter/source/config/cache/filtercache.hxx b/filter/source/config/cache/filtercache.hxx
index 8cb34701cc2a..2f647c33e708 100644
--- a/filter/source/config/cache/filtercache.hxx
+++ b/filter/source/config/cache/filtercache.hxx
@@ -361,9 +361,9 @@ class FilterCache : public cppu::BaseMutex
if some input parameter are wrong or the cache itself is not valid
any longer, because any operation before damage it.
*/
- std::vector<OUString> getMatchingItemsByProps( EItemType eType ,
- const CacheItem& lIProps ,
- const CacheItem& lEProps = CacheItem()) const;
+ std::vector<OUString> getMatchingItemsByProps( EItemType eType,
+ o3tl::span< const css::beans::NamedValue > lIProps,
+ o3tl::span< const css::beans::NamedValue > lEProps = {}) const;
/** @short indicates if the requested sub container
diff --git a/filter/source/config/cache/filterfactory.cxx b/filter/source/config/cache/filterfactory.cxx
index d98b2f3174e7..586229cb78c5 100644
--- a/filter/source/config/cache/filterfactory.cxx
+++ b/filter/source/config/cache/filterfactory.cxx
@@ -121,14 +121,13 @@ css::uno::Sequence< OUString > SAL_CALL FilterFactory::getAvailableServiceNames(
Of course we can't check for corrupted service names here. We can check
for empty strings only...
*/
- CacheItem lIProps;
- CacheItem lEProps;
- lEProps[PROPNAME_FILTERSERVICE] <<= OUString();
+ css::beans::NamedValue lEProps[] {
+ { PROPNAME_FILTERSERVICE, css::uno::Any(OUString()) } };
std::vector<OUString> lUNOFilters;
try
{
- lUNOFilters = GetTheFilterCache().getMatchingItemsByProps(FilterCache::E_FILTER, lIProps, lEProps);
+ lUNOFilters = GetTheFilterCache().getMatchingItemsByProps(FilterCache::E_FILTER, {}, lEProps);
}
catch(const css::uno::RuntimeException&)
{ throw; }
@@ -420,8 +419,7 @@ std::vector<OUString> FilterFactory::impl_getSortedFilterListForModule(const OUS
std::vector<OUString> lSortedFilters = impl_readSortedFilterListFromConfig(sModule);
// get all filters for the requested module
- CacheItem lIProps;
- lIProps[PROPNAME_DOCUMENTSERVICE] <<= sModule;
+ css::beans::NamedValue lIProps[] { { PROPNAME_DOCUMENTSERVICE, css::uno::Any(sModule) } };
// SAFE -> ----------------------
osl::ClearableMutexGuard aLock(m_aMutex);
diff --git a/filter/source/config/cache/typedetection.cxx b/filter/source/config/cache/typedetection.cxx
index 8ea578f7161a..88402fbfc672 100644
--- a/filter/source/config/cache/typedetection.cxx
+++ b/filter/source/config/cache/typedetection.cxx
@@ -496,9 +496,9 @@ void TypeDetection::impl_checkResultsAndAddBestFilter(utl::MediaDescriptor& rDes
// That can disturb our "load on demand feature". But we have no other chance!
cache.load(FilterCache::E_CONTAINS_FILTERS);
- CacheItem lIProps;
- lIProps[PROPNAME_DOCUMENTSERVICE] <<= sDocumentService;
- lIProps[PROPNAME_TYPE ] <<= sRealType;
+ css::beans::NamedValue lIProps[] {
+ { PROPNAME_DOCUMENTSERVICE, uno::Any(sDocumentService) },
+ { PROPNAME_TYPE, uno::Any(sRealType) } };
std::vector<OUString> lFilters = cache.getMatchingItemsByProps(FilterCache::E_FILTER, lIProps);
aLock.clear();
@@ -577,8 +577,8 @@ void TypeDetection::impl_checkResultsAndAddBestFilter(utl::MediaDescriptor& rDes
// That can disturb our "load on demand feature". But we have no other chance!
cache.load(FilterCache::E_CONTAINS_FILTERS);
- CacheItem lIProps;
- lIProps[PROPNAME_TYPE] <<= sType;
+ css::beans::NamedValue lIProps[] {
+ { PROPNAME_TYPE, uno::Any(sType) } };
std::vector<OUString> lFilters = cache.getMatchingItemsByProps(FilterCache::E_FILTER, lIProps);
aLock.clear();
@@ -736,8 +736,8 @@ void TypeDetection::impl_getPreselectionForDocumentService(
auto & cache = GetTheFilterCache();
cache.load(FilterCache::E_CONTAINS_FILTERS);
- CacheItem lIProps;
- lIProps[PROPNAME_DOCUMENTSERVICE] <<= sPreSelDocumentService;
+ css::beans::NamedValue lIProps[] {
+ { PROPNAME_DOCUMENTSERVICE, css::uno::Any(sPreSelDocumentService) } };
lFilters = cache.getMatchingItemsByProps(FilterCache::E_FILTER, lIProps);
// <- SAFE --------------------------
}