Skip to content

Commit 5bf2639

Browse files
committed
Eliminate unnecessary string copy
1 parent 31e6ce8 commit 5bf2639

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

source/svgelement.cpp

+5-5
Original file line numberDiff line numberDiff line change
@@ -142,12 +142,12 @@ const std::string& SVGElement::getAttribute(const std::string_view& name) const
142142
return getAttribute(id);
143143
}
144144

145-
bool SVGElement::setAttribute(const std::string_view& name, std::string value)
145+
bool SVGElement::setAttribute(const std::string_view& name, const std::string& value)
146146
{
147147
auto id = propertyid(name);
148148
if(id == PropertyID::Unknown)
149149
return false;
150-
return setAttribute(0x1000, id, std::move(value));
150+
return setAttribute(0x1000, id, value);
151151
}
152152

153153
const Attribute* SVGElement::findAttribute(PropertyID id) const
@@ -183,20 +183,20 @@ const std::string& SVGElement::getAttribute(PropertyID id) const
183183
return emptyString;
184184
}
185185

186-
bool SVGElement::setAttribute(int specificity, PropertyID id, std::string value)
186+
bool SVGElement::setAttribute(int specificity, PropertyID id, const std::string& value)
187187
{
188188
for(auto& attribute : m_attributes) {
189189
if(id == attribute.id()) {
190190
if(specificity < attribute.specificity())
191191
return false;
192192
parseAttribute(id, value);
193-
attribute = Attribute(specificity, id, std::move(value));
193+
attribute = Attribute(specificity, id, value);
194194
return true;
195195
}
196196
}
197197

198198
parseAttribute(id, value);
199-
m_attributes.emplace_front(specificity, id, std::move(value));
199+
m_attributes.emplace_front(specificity, id, value);
200200
return true;
201201
}
202202

source/svgelement.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -126,12 +126,12 @@ class SVGElement : public SVGNode {
126126

127127
bool hasAttribute(const std::string_view& name) const;
128128
const std::string& getAttribute(const std::string_view& name) const;
129-
bool setAttribute(const std::string_view& name, std::string value);
129+
bool setAttribute(const std::string_view& name, const std::string& value);
130130

131131
const Attribute* findAttribute(PropertyID id) const;
132132
bool hasAttribute(PropertyID id) const;
133133
const std::string& getAttribute(PropertyID id) const;
134-
bool setAttribute(int specificity, PropertyID id, std::string value);
134+
bool setAttribute(int specificity, PropertyID id, const std::string& value);
135135
void setAttributes(const AttributeList& attributes);
136136
bool setAttribute(const Attribute& attribute);
137137

0 commit comments

Comments
 (0)