diff options
author | Mike Kaganski <mike.kaganski@collabora.com> | 2021-08-24 09:49:56 +0200 |
---|---|---|
committer | Mike Kaganski <mike.kaganski@collabora.com> | 2021-08-24 13:41:17 +0200 |
commit | 97b7511acfd9593051a611c71d307916097256dd (patch) | |
tree | 3dda794641166c21dc8cb7563b585e500e6f4c52 /comphelper | |
parent | baed91bab05546f7f5233701bd7aaed44f25a364 (diff) |
Simplify caching in ConfigurationWrapper
A follow-up to 48c2f0b4b157e133605c99549893521775ede4da
This allows to not call createInstanceWithArguments repeatedly.
Change-Id: I1893b9b1b0f952ae7c650bab4fb0dfe2f331a129
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/120883
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Tested-by: Jenkins
Diffstat (limited to 'comphelper')
-rw-r--r-- | comphelper/source/misc/configuration.cxx | 24 |
1 files changed, 9 insertions, 15 deletions
diff --git a/comphelper/source/misc/configuration.cxx b/comphelper/source/misc/configuration.cxx index 3e8bb31ebb8a..67009cd9f864 100644 --- a/comphelper/source/misc/configuration.cxx +++ b/comphelper/source/misc/configuration.cxx @@ -15,7 +15,6 @@ #include <mutex> #include <string_view> -#include <com/sun/star/beans/NamedValue.hpp> #include <com/sun/star/beans/PropertyAttribute.hpp> #include <com/sun/star/configuration/ReadOnlyAccess.hpp> #include <com/sun/star/configuration/ReadWriteAccess.hpp> @@ -131,8 +130,7 @@ bool comphelper::detail::ConfigurationWrapper::isReadOnly(OUString const & path) != 0; } -css::uno::Any comphelper::detail::ConfigurationWrapper::getPropertyValue(css::uno::Reference< css::uno::XComponentContext > const & context, - OUString const & path) +css::uno::Any comphelper::detail::ConfigurationWrapper::getPropertyValue(OUString const& path) const { // Cache the configuration access, since some of the keys are used in hot code. // Note that this cache is only used by the officecfg:: auto-generated code, using it for anything @@ -149,18 +147,14 @@ css::uno::Any comphelper::detail::ConfigurationWrapper::getPropertyValue(css::un // check cache auto it = gAccessMap.find(parentPath); - if (it != gAccessMap.end()) - return it->second->getByName(childName); - - // not in the cache, look it up - css::uno::Reference< css::lang::XMultiServiceFactory > provider = css::configuration::theDefaultProvider::get( - context ); - css::uno::Any arg(css::beans::NamedValue("nodepath", css::uno::Any(parentPath))); - css::uno::Reference< css::container::XNameAccess > access(provider->createInstanceWithArguments( - "com.sun.star.configuration.ConfigurationAccess", - { arg }), css::uno::UNO_QUERY_THROW); - gAccessMap.emplace(parentPath, access); - return access->getByName(childName); + if (it == gAccessMap.end()) + { + // not in the cache, look it up + css::uno::Reference<css::container::XNameAccess> access( + access_->getByHierarchicalName(parentPath), css::uno::UNO_QUERY_THROW); + it = gAccessMap.emplace(parentPath, access).first; + } + return it->second->getByName(childName); } void comphelper::detail::ConfigurationWrapper::setPropertyValue( |