diff options
author | Luboš Luňák <l.lunak@collabora.com> | 2022-03-05 11:23:38 +0100 |
---|---|---|
committer | Luboš Luňák <l.lunak@collabora.com> | 2022-03-07 15:37:22 +0100 |
commit | 4256c764aee0777770466115a97420d9b55c23ac (patch) | |
tree | 9452b0dc5c84355826d070ad3eccba498ef9c5e8 /include/comphelper | |
parent | 58c6a36bfcc853ca9da81fbc2d071fa50585655b (diff) |
do not pass XComponentContext to officecfg::...::get() calls
It's used only for the ConfigurationWrapper singleton, so it's used
only the first time and then ignored. It also causes calls to
comphelper::getProcessComponentContext() for every single invocation
despite the value not being needed, and the calls may not be cheap
(it's ~5% CPU during ODS save because relatively frequent calls
to officecfg::Office::Common::Save::ODF::DefaultVersion::get()).
Change-Id: I02c17a1a9cb498aeef220ddd5a0bde5523cb0ffb
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/131056
Tested-by: Jenkins
Reviewed-by: Luboš Luňák <l.lunak@collabora.com>
Diffstat (limited to 'include/comphelper')
-rw-r--r-- | include/comphelper/configuration.hxx | 34 |
1 files changed, 12 insertions, 22 deletions
diff --git a/include/comphelper/configuration.hxx b/include/comphelper/configuration.hxx index 1ed37dcd45c3..8525b816a3c5 100644 --- a/include/comphelper/configuration.hxx +++ b/include/comphelper/configuration.hxx @@ -46,9 +46,7 @@ namespace detail { class ConfigurationWrapper; } /// directly. class COMPHELPER_DLLPUBLIC ConfigurationChanges { public: - static std::shared_ptr<ConfigurationChanges> create( - css::uno::Reference< css::uno::XComponentContext > - const & context = comphelper::getProcessComponentContext()); + static std::shared_ptr<ConfigurationChanges> create(); ~ConfigurationChanges(); @@ -85,9 +83,7 @@ namespace detail { /// @internal class COMPHELPER_DLLPUBLIC ConfigurationWrapper { public: - static ConfigurationWrapper const & get( - css::uno::Reference< css::uno::XComponentContext > - const & context); + static ConfigurationWrapper const & get(); SAL_DLLPRIVATE explicit ConfigurationWrapper( css::uno::Reference< css::uno::XComponentContext > @@ -193,24 +189,20 @@ template< typename T, typename U > struct ConfigurationProperty { /// Get the read-only status of the given (non-localized) configuration /// property. - static bool isReadOnly( - css::uno::Reference<css::uno::XComponentContext> const & context - = comphelper::getProcessComponentContext()) + static bool isReadOnly() { - return detail::ConfigurationWrapper::get(context).isReadOnly(T::path()); + return detail::ConfigurationWrapper::get().isReadOnly(T::path()); } /// Get the value of the given (non-localized) configuration property. /// /// For nillable properties, U is of type std::optional<U'>. - static U get( - css::uno::Reference< css::uno::XComponentContext > - const & context = comphelper::getProcessComponentContext()) + static U get() { // Folding this into one statement causes a bogus error at least with // Red Hat GCC 4.6.2-1: css::uno::Any a( - detail::ConfigurationWrapper::get(context).getPropertyValue( + detail::ConfigurationWrapper::get().getPropertyValue( T::path())); return detail::Convert< U >::fromAny(a); } @@ -247,12 +239,12 @@ template< typename T, typename U > struct ConfigurationLocalizedProperty /// com.sun.star.configuration.theDefaultProvider. /// /// For nillable properties, U is of type std::optional<U'>. - static U get(css::uno::Reference< css::uno::XComponentContext > const & context) + static U get() { // Folding this into one statement causes a bogus error at least with // Red Hat GCC 4.6.2-1: css::uno::Any a( - detail::ConfigurationWrapper::get(context). + detail::ConfigurationWrapper::get(). getLocalizedPropertyValue(T::path())); return detail::Convert< U >::fromAny(a); } @@ -288,10 +280,9 @@ template< typename T > struct ConfigurationGroup { /// Get read-only access to the given configuration group. static css::uno::Reference< css::container::XHierarchicalNameAccess > - get(css::uno::Reference< css::uno::XComponentContext > - const & context = comphelper::getProcessComponentContext()) + get() { - return detail::ConfigurationWrapper::get(context).getGroupReadOnly( + return detail::ConfigurationWrapper::get().getGroupReadOnly( T::path()); } @@ -322,10 +313,9 @@ template< typename T > struct ConfigurationSet { /// Get read-only access to the given configuration set. static css::uno::Reference< css::container::XNameAccess > - get(css::uno::Reference< css::uno::XComponentContext > - const & context = comphelper::getProcessComponentContext()) + get() { - return detail::ConfigurationWrapper::get(context).getSetReadOnly( + return detail::ConfigurationWrapper::get().getSetReadOnly( T::path()); } |