summaryrefslogtreecommitdiff
path: root/configmgr
diff options
context:
space:
mode:
authorMichael Meeks <michael.meeks@collabora.com>2014-06-26 13:47:54 +0100
committerMichael Meeks <michael.meeks@collabora.com>2014-06-28 14:37:22 +0100
commitf692c61ab26b425cd8e6a36b8e229bbf7caff335 (patch)
tree5aac9f0a1810e9265901b86e8c37fe560c45df7e /configmgr
parent115fd951e92a725ee6fca41e96d6b791ac66bd34 (diff)
configmgr: avoid constructing duplicating and freeing Any's
Accelerates headless startup by 6.5m cycles or so, 0.6% or so but something. Change-Id: I9edca3d0c1c81d865e8369fee5cf193da7adb97c
Diffstat (limited to 'configmgr')
-rw-r--r--configmgr/source/localizedvaluenode.cxx10
-rw-r--r--configmgr/source/localizedvaluenode.hxx8
-rw-r--r--configmgr/source/propertynode.cxx7
-rw-r--r--configmgr/source/propertynode.hxx1
-rw-r--r--configmgr/source/valueparser.cxx67
5 files changed, 57 insertions, 36 deletions
diff --git a/configmgr/source/localizedvaluenode.cxx b/configmgr/source/localizedvaluenode.cxx
index 27b977d2d824..3c7bbdce5d25 100644
--- a/configmgr/source/localizedvaluenode.cxx
+++ b/configmgr/source/localizedvaluenode.cxx
@@ -33,6 +33,10 @@ LocalizedValueNode::LocalizedValueNode(int layer, css::uno::Any const & value):
Node(layer), value_(value)
{}
+LocalizedValueNode::LocalizedValueNode(int layer):
+ Node(layer)
+{}
+
rtl::Reference< Node > LocalizedValueNode::clone(bool) const {
return new LocalizedValueNode(*this);
}
@@ -42,9 +46,11 @@ OUString LocalizedValueNode::getTemplateName() const {
}
-void LocalizedValueNode::setValue(int layer, css::uno::Any const & value) {
+void LocalizedValueNode::setValue(int layer, css::uno::Any const & value)
+{
setLayer(layer);
- value_ = value;
+ if (&value != &value_)
+ value_ = value;
}
LocalizedValueNode::LocalizedValueNode(LocalizedValueNode const & other):
diff --git a/configmgr/source/localizedvaluenode.hxx b/configmgr/source/localizedvaluenode.hxx
index 08635f875251..98b012ad501e 100644
--- a/configmgr/source/localizedvaluenode.hxx
+++ b/configmgr/source/localizedvaluenode.hxx
@@ -32,13 +32,19 @@ namespace configmgr {
class LocalizedValueNode: public Node {
public:
+ LocalizedValueNode(int layer);
LocalizedValueNode(int layer, com::sun::star::uno::Any const & value);
virtual rtl::Reference< Node > clone(bool keepTemplateName) const SAL_OVERRIDE;
virtual OUString getTemplateName() const SAL_OVERRIDE;
- com::sun::star::uno::Any getValue() const { return value_;}
+ com::sun::star::uno::Any getValue() const { return value_;}
+ com::sun::star::uno::Any *getValuePtr(int layer)
+ {
+ setLayer(layer);
+ return &value_;
+ }
void setValue(int layer, com::sun::star::uno::Any const & value);
diff --git a/configmgr/source/propertynode.cxx b/configmgr/source/propertynode.cxx
index 456091359ebf..102423aabafe 100644
--- a/configmgr/source/propertynode.cxx
+++ b/configmgr/source/propertynode.cxx
@@ -69,6 +69,13 @@ void PropertyNode::setValue(int layer, css::uno::Any const & value) {
externalDescriptor_ = "";
}
+com::sun::star::uno::Any *PropertyNode::getValuePtr(int layer)
+{
+ setLayer(layer);
+ externalDescriptor_ = "";
+ return &value_;
+}
+
void PropertyNode::setExternal(int layer, OUString const & descriptor) {
assert(!descriptor.isEmpty());
setLayer(layer);
diff --git a/configmgr/source/propertynode.hxx b/configmgr/source/propertynode.hxx
index 60108e7db6ea..805efa18de65 100644
--- a/configmgr/source/propertynode.hxx
+++ b/configmgr/source/propertynode.hxx
@@ -48,6 +48,7 @@ public:
com::sun::star::uno::Any getValue(Components & components);
void setValue(int layer, com::sun::star::uno::Any const & value);
+ com::sun::star::uno::Any *getValuePtr(int layer);
void setExternal(int layer, OUString const & descriptor);
diff --git a/configmgr/source/valueparser.cxx b/configmgr/source/valueparser.cxx
index 5c140f6f4dff..a12d0729f79a 100644
--- a/configmgr/source/valueparser.cxx
+++ b/configmgr/source/valueparser.cxx
@@ -345,32 +345,57 @@ bool ValueParser::endElement() {
switch (state_) {
case STATE_TEXT:
{
- css::uno::Any value;
+ css::uno::Any *pValue = NULL;
+
+ switch (node_->kind()) {
+ case Node::KIND_PROPERTY:
+ pValue = static_cast< PropertyNode * >(node_.get())->getValuePtr(layer_);
+ break;
+ case Node::KIND_LOCALIZED_PROPERTY:
+ {
+ NodeMap & members = node_->getMembers();
+ NodeMap::iterator i(members.find(localizedName_));
+ LocalizedValueNode *pLVNode;
+ if (i == members.end()) {
+ pLVNode = new LocalizedValueNode(layer_);
+ members.insert(
+ NodeMap::value_type(localizedName_, pLVNode));
+ } else {
+ pLVNode = static_cast< LocalizedValueNode * >(i->second.get());
+ }
+ pValue = pLVNode->getValuePtr(layer_);
+ }
+ break;
+ default:
+ assert(false); // this cannot happen
+ return false;
+ }
+
if (items_.empty()) {
- value = parseValue(separator_, pad_.get(), type_);
+ *pValue = parseValue(separator_, pad_.get(), type_);
pad_.clear();
} else {
switch (type_) {
case TYPE_BOOLEAN_LIST:
- value = convertItems< sal_Bool >();
+ *pValue = convertItems< sal_Bool >();
break;
case TYPE_SHORT_LIST:
- value = convertItems< sal_Int16 >();
+ *pValue = convertItems< sal_Int16 >();
break;
case TYPE_INT_LIST:
- value = convertItems< sal_Int32 >();
+ *pValue = convertItems< sal_Int32 >();
break;
case TYPE_LONG_LIST:
- value = convertItems< sal_Int64 >();
+ *pValue = convertItems< sal_Int64 >();
break;
case TYPE_DOUBLE_LIST:
- value = convertItems< double >();
+ *pValue = convertItems< double >();
break;
case TYPE_STRING_LIST:
- value = convertItems< OUString >();
+ *pValue = convertItems< OUString >();
break;
case TYPE_HEXBINARY_LIST:
- value = convertItems< css::uno::Sequence< sal_Int8 > >();
+ *pValue = convertItems< css::uno::Sequence< sal_Int8 > >();
break;
default:
assert(false); // this cannot happen
@@ -378,30 +403,6 @@ bool ValueParser::endElement() {
}
items_.clear();
}
- switch (node_->kind()) {
- case Node::KIND_PROPERTY:
- static_cast< PropertyNode * >(node_.get())->setValue(
- layer_, value);
- break;
- case Node::KIND_LOCALIZED_PROPERTY:
- {
- NodeMap & members = node_->getMembers();
- NodeMap::iterator i(members.find(localizedName_));
- if (i == members.end()) {
- members.insert(
- NodeMap::value_type(
- localizedName_,
- new LocalizedValueNode(layer_, value)));
- } else {
- static_cast< LocalizedValueNode * >(i->second.get())->
- setValue(layer_, value);
- }
- }
- break;
- default:
- assert(false); // this cannot happen
- break;
- }
separator_ = OString();
node_.clear();
}