Skip to content

Commit ad8ddd7

Browse files
committed
toupper/tolower is already receiving a copy, so it doesn't need to create a new one to transform it
1 parent 43c6d0d commit ad8ddd7

File tree

1 file changed

+4
-10
lines changed

1 file changed

+4
-10
lines changed

src/utils/string.cc

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -154,28 +154,22 @@ std::string toHexIfNeeded(const std::string &str, bool escape_spec) {
154154

155155

156156
std::string tolower(std::string str) {
157-
std::string value;
158-
value.resize(str.length());
159-
160157
std::transform(str.begin(),
161158
str.end(),
162-
value.begin(),
159+
str.begin(),
163160
::tolower);
164161

165-
return value;
162+
return str;
166163
}
167164

168165

169166
std::string toupper(std::string str) {
170-
std::string value;
171-
value.resize(str.length());
172-
173167
std::transform(str.begin(),
174168
str.end(),
175-
value.begin(),
169+
str.begin(),
176170
::toupper);
177171

178-
return value;
172+
return str;
179173
}
180174

181175

0 commit comments

Comments
 (0)