Skip to content

Commit ba070c9

Browse files
author
Felipe Zimmerle
committed
Speeds up utils::string::toupper function
1 parent b3c8e97 commit ba070c9

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

src/utils/string.cc

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -140,12 +140,13 @@ std::string tolower(std::string str) {
140140

141141

142142
std::string toupper(std::string str) {
143-
std::locale loc;
144143
std::string value;
144+
value.resize(str.length());
145145

146-
for (std::string::size_type i=0; i < str.length(); ++i) {
147-
value.assign(value + std::toupper(str[i], loc));
148-
}
146+
std::transform(str.begin(),
147+
str.end(),
148+
value.begin(),
149+
::toupper);
149150

150151
return value;
151152
}

0 commit comments

Comments
 (0)