Skip to content

Commit 89a6f0b

Browse files
committed
Clarify/optimize to_ascii_lower
1 parent ea7e5cf commit 89a6f0b

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

jsonh_cpp/jsonh_reader.hpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1058,7 +1058,7 @@ class jsonh_reader : utf8_reader {
10581058
}
10591059

10601060
// Digit
1061-
if (base_digits.find(to_lower(next.value().data())) != std::string::npos) {
1061+
if (base_digits.find(to_ascii_lower(next.value().data())) != std::string::npos) {
10621062
read();
10631063
number_builder += next.value();
10641064
}
@@ -1398,10 +1398,12 @@ class jsonh_reader : utf8_reader {
13981398
static bool is_utf16_high_surrogate(unsigned int code_point) noexcept {
13991399
return code_point >= 0xD800 && code_point <= 0xDBFF;
14001400
}
1401-
static std::string to_lower(const char* string) noexcept {
1401+
static std::string to_ascii_lower(const char* string) noexcept {
14021402
std::string result(string);
14031403
for (char& next : result) {
1404-
next = std::tolower(next);
1404+
if (next <= 'Z' && next >= 'A') {
1405+
next -= ('Z' - 'z');
1406+
}
14051407
}
14061408
return result;
14071409
}

0 commit comments

Comments
 (0)