summaryrefslogtreecommitdiffstats
path: root/src/preferences.cpp
diff options
context:
space:
mode:
authorMarc Jeanmougin <marc@jeanmougin.fr>2018-09-11 14:31:15 +0000
committerMarc Jeanmougin <marc@jeanmougin.fr>2018-09-11 14:31:15 +0000
commita81d0009254a86479a012eb53ec1b7e24a4334d0 (patch)
tree8114c60abbc4a44b05aa784eb87315043432878b /src/preferences.cpp
parentMake XML tree a double-linked-list (significant improvement on previous node ... (diff)
downloadinkscape-a81d0009254a86479a012eb53ec1b7e24a4334d0.tar.gz
inkscape-a81d0009254a86479a012eb53ec1b7e24a4334d0.zip
Cache preference raw values
Diffstat (limited to 'src/preferences.cpp')
-rw-r--r--src/preferences.cpp6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/preferences.cpp b/src/preferences.cpp
index 1c4951d75..e05767757 100644
--- a/src/preferences.cpp
+++ b/src/preferences.cpp
@@ -505,6 +505,9 @@ void Preferences::mergeStyle(Glib::ustring const &pref_path, SPCSSAttr *style)
*/
void Preferences::remove(Glib::ustring const &pref_path)
{
+ auto it = cachedRawValue.find(pref_path);
+ if (it != cachedRawValue.end()) cachedRawValue.erase(it);
+
Inkscape::XML::Node *node = _getNode(pref_path, false);
if (node && node->parent()) {
node->parent()->removeChild(node);
@@ -746,6 +749,7 @@ Inkscape::XML::Node *Preferences::_getNode(Glib::ustring const &pref_key, bool c
void Preferences::_getRawValue(Glib::ustring const &path, gchar const *&result)
{
+ if (cachedRawValue.find(path)!=cachedRawValue.end()) { result = cachedRawValue.at(path); return; }
// create node and attribute keys
Glib::ustring node_key, attr_key;
_keySplit(path, node_key, attr_key);
@@ -762,6 +766,7 @@ void Preferences::_getRawValue(Glib::ustring const &path, gchar const *&result)
result = attr;
}
}
+ cachedRawValue[path] = result;
}
void Preferences::_setRawValue(Glib::ustring const &path, Glib::ustring const &value)
@@ -773,6 +778,7 @@ void Preferences::_setRawValue(Glib::ustring const &path, Glib::ustring const &v
// set the attribute
Inkscape::XML::Node *node = _getNode(node_key, true);
node->setAttribute(attr_key.c_str(), value.c_str());
+ cachedRawValue[path] = value.c_str();
}
// The _extract* methods are where the actual work is done - they define how preferences are stored