summaryrefslogtreecommitdiffstats
path: root/configmgr/source/access.cxx
diff options
context:
space:
mode:
authorMichael Meeks <michael.meeks@collabora.com>2014-06-28 14:18:32 +0100
committerMichael Meeks <michael.meeks@collabora.com>2014-06-28 14:37:24 +0100
commit879aa54e895a56cb65f93ae98e6a9e7b08981a47 (patch)
treeaa45237fb0ad9bb45d563d32e2fd7b789581c1d2 /configmgr/source/access.cxx
parentfilters: Batch fetch filter config properties. (diff)
downloadcore-879aa54e895a56cb65f93ae98e6a9e7b08981a47.tar.gz
core-879aa54e895a56cb65f93ae98e6a9e7b08981a47.zip
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
Diffstat (limited to 'configmgr/source/access.cxx')
-rw-r--r--configmgr/source/access.cxx67
1 files changed, 54 insertions, 13 deletions
diff --git a/configmgr/source/access.cxx b/configmgr/source/access.cxx
index 665b3cdd422f..6aeabb41abab 100644
--- a/configmgr/source/access.cxx
+++ b/configmgr/source/access.cxx
@@ -344,6 +344,42 @@ sal_Bool Access::hasElements() throw (css::uno::RuntimeException, std::exception
return !getAllChildren().empty(); //TODO: optimize
}
+bool Access::getByNameFast(const OUString & name, css::uno::Any & value)
+{
+ bool bGotValue = false;
+ rtl::Reference< ChildAccess > child;
+
+ if (getNode()->kind() != Node::KIND_LOCALIZED_PROPERTY)
+ { // try to get it directly
+ ModifiedChildren::iterator i(modifiedChildren_.find(name));
+ if (i != modifiedChildren_.end())
+ {
+ child = getModifiedChild(i);
+ if (child.is())
+ {
+ value = child->asValue();
+ bGotValue = true;
+ }
+ }
+ else
+ {
+ rtl::Reference< Node > node(getNode()->getMember(name));
+ if (!node.is())
+ return false;
+ bGotValue = ChildAccess::asSimpleValue(node, value, components_);
+ }
+ }
+
+ if (!bGotValue)
+ {
+ child = getChild(name);
+ if (!child.is())
+ return false;
+ value = child->asValue();
+ }
+ return true;
+}
+
css::uno::Any Access::getByName(OUString const & aName)
throw (
css::container::NoSuchElementException,
@@ -352,12 +388,11 @@ css::uno::Any Access::getByName(OUString const & aName)
assert(thisIs(IS_ANY));
osl::MutexGuard g(*lock_);
checkLocalizedPropertyAccess();
- rtl::Reference< ChildAccess > child(getChild(aName));
- if (!child.is()) {
+ css::uno::Any value;
+ if (!getByNameFast(aName, value))
throw css::container::NoSuchElementException(
aName, static_cast< cppu::OWeakObject * >(this));
- }
- return child->asValue();
+ return value;
}
css::uno::Sequence< OUString > Access::getElementNames()
@@ -852,15 +887,15 @@ css::uno::Sequence< css::uno::Any > Access::getPropertyValues(
assert(thisIs(IS_GROUP));
osl::MutexGuard g(*lock_);
css::uno::Sequence< css::uno::Any > vals(aPropertyNames.getLength());
- for (sal_Int32 i = 0; i < aPropertyNames.getLength(); ++i) {
- rtl::Reference< ChildAccess > child(getChild(aPropertyNames[i]));
- if (!child.is()) {
+
+ for (sal_Int32 i = 0; i < aPropertyNames.getLength(); ++i)
+ {
+ if (!getByNameFast(aPropertyNames[i], vals[i]))
throw css::uno::RuntimeException(
"configmgr getPropertyValues inappropriate property name",
static_cast< cppu::OWeakObject * >(this));
- }
- vals[i] = child->asValue();
}
+
return vals;
}
@@ -1988,6 +2023,15 @@ rtl::Reference< ChildAccess > Access::getModifiedChild(
? childIterator->second.child : rtl::Reference< ChildAccess >();
}
+rtl::Reference< ChildAccess > Access::createUnmodifiedChild(
+ const OUString &name, const rtl::Reference< Node > &node)
+{
+ rtl::Reference< ChildAccess > child(
+ new ChildAccess(components_, getRootAccess(), this, name, node));
+ cachedChildren_[name] = child.get();
+ return child;
+}
+
rtl::Reference< ChildAccess > Access::getUnmodifiedChild(
OUString const & name)
{
@@ -2008,10 +2052,7 @@ rtl::Reference< ChildAccess > Access::getUnmodifiedChild(
return child;
}
}
- rtl::Reference< ChildAccess > child(
- new ChildAccess(components_, getRootAccess(), this, name, node));
- cachedChildren_[name] = child.get();
- return child;
+ return createUnmodifiedChild(name,node);
}
rtl::Reference< ChildAccess > Access::getSubChild(OUString const & path) {