From 879aa54e895a56cb65f93ae98e6a9e7b08981a47 Mon Sep 17 00:00:00 2001 From: Michael Meeks Date: Sat, 28 Jun 2014 14:18:32 +0100 Subject: configmgr: accelerate simple config key fetches. Avoid heap allocating UNO object wrappers for the underlying Node structures only to convert to Any and immediately free them agian when we can. Change-Id: Iae4612e9602f872f5d8cca2e516df594c9f1118c --- configmgr/source/childaccess.cxx | 41 +++++++++++++++++++++++++++------------- 1 file changed, 28 insertions(+), 13 deletions(-) (limited to 'configmgr/source/childaccess.cxx') diff --git a/configmgr/source/childaccess.cxx b/configmgr/source/childaccess.cxx index dc7822e00926..259d968d76ee 100644 --- a/configmgr/source/childaccess.cxx +++ b/configmgr/source/childaccess.cxx @@ -252,33 +252,48 @@ void ChildAccess::setProperty( localModifications->add(getRelativePath()); } -css::uno::Any ChildAccess::asValue() { + +css::uno::Any ChildAccess::asValue() +{ if (changedValue_.get() != 0) { return *changedValue_; } - switch (node_->kind()) { - case Node::KIND_PROPERTY: - return static_cast< PropertyNode * >(node_.get())->getValue( - getComponents()); - case Node::KIND_LOCALIZED_PROPERTY: + css::uno::Any value; + if (!asSimpleValue(node_, value, getComponents())) + { + if (node_->kind() == Node::KIND_LOCALIZED_PROPERTY) { OUString locale(getRootAccess()->getLocale()); if (!Components::allLocales(locale)) { rtl::Reference< ChildAccess > child(getChild("*" + locale)); // As a last resort, return a nil value even though it may be // illegal for the given property: - return child.is() ? child->asValue() : css::uno::Any(); + if (child.is()) + return child->asValue(); } } - break; + value = css::uno::makeAny( + css::uno::Reference< css::uno::XInterface >( + static_cast< cppu::OWeakObject * >(this))); + } + return value; +} + +/// Can we quickly extract a simple value into value ? if so returns true +bool ChildAccess::asSimpleValue(const rtl::Reference< Node > &rNode, + css::uno::Any &value, + Components &components) +{ + switch (rNode->kind()) { + case Node::KIND_PROPERTY: + value = static_cast< PropertyNode * >(rNode.get())->getValue(components); + return true; case Node::KIND_LOCALIZED_VALUE: - return static_cast< LocalizedValueNode * >(node_.get())->getValue(); + value = static_cast< LocalizedValueNode * >(rNode.get())->getValue(); + return true; default: - break; + return false; } - return css::uno::makeAny( - css::uno::Reference< css::uno::XInterface >( - static_cast< cppu::OWeakObject * >(this))); } void ChildAccess::commitChanges(bool valid, Modifications * globalModifications) -- cgit