summaryrefslogtreecommitdiffstats
path: root/src/style.cpp
diff options
context:
space:
mode:
authorMarc Jeanmougin <marc@jeanmougin.fr>2019-01-01 10:08:57 +0000
committerMarc Jeanmougin <marc@jeanmougin.fr>2019-01-01 10:08:57 +0000
commit1f70a51c7136ddc15615cc21ab03beea58df5887 (patch)
treefe128c76844003aef0fb78a6040816847840b4ff /src/style.cpp
parentMerge branch 'items-to-intrusive-list' of gitlab.com:ollip/inkscape (diff)
parentsp_attribute_lookup with std::map (diff)
downloadinkscape-1f70a51c7136ddc15615cc21ab03beea58df5887.tar.gz
inkscape-1f70a51c7136ddc15615cc21ab03beea58df5887.zip
Merge remote-tracking branch 'origin/attribute-lookup-map'
Diffstat (limited to 'src/style.cpp')
-rw-r--r--src/style.cpp15
1 files changed, 3 insertions, 12 deletions
diff --git a/src/style.cpp b/src/style.cpp
index aab8f2695..b11a92749 100644
--- a/src/style.cpp
+++ b/src/style.cpp
@@ -76,7 +76,7 @@ static CRSelEng *sp_repr_sel_eng();
class SPStylePropHelper {
SPStylePropHelper() {
#define REGISTER_PROPERTY(id, member, name) \
- _register(reinterpret_cast<SPIBasePtr>(&SPStyle::member), id, name)
+ _register(reinterpret_cast<SPIBasePtr>(&SPStyle::member), id) /* name unused */
// SVG 2: Attributes promoted to properties
REGISTER_PROPERTY(SP_ATTR_D, d, "d");
@@ -215,11 +215,7 @@ public:
* Get property pointer by name
*/
SPIBase *get(SPStyle *style, const std::string &name) {
- auto it = m_name_map.find(name);
- if (it != m_name_map.end()) {
- return _get(style, it->second);
- }
- return nullptr;
+ return get(style, sp_attribute_lookup(name.c_str()));
}
/**
@@ -238,19 +234,14 @@ public:
private:
SPIBase *_get(SPStyle *style, SPIBasePtr ptr) { return &(style->*ptr); }
- void _register(SPIBasePtr ptr, SPAttributeEnum id, const char *name) {
+ void _register(SPIBasePtr ptr, SPAttributeEnum id) {
m_vector.push_back(ptr);
if (id != SP_ATTR_INVALID) {
m_id_map[id] = ptr;
}
-
- if (name[0]) {
- m_name_map[name] = ptr;
- }
}
- std::unordered_map<std::string, SPIBasePtr> m_name_map;
std::unordered_map</* SPAttributeEnum */ int, SPIBasePtr> m_id_map;
std::vector<SPIBasePtr> m_vector;
};