Skip to content

Commit 10dc45b

Browse files
committed
Don't create tons of locales when parsing URIs
This is a major performance bottleneck when parsing URIs as creating locales is quite expensive.
1 parent ab3a3ac commit 10dc45b

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/detail/grammar.hpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ namespace detail {
1717
inline bool isalnum(string_view::const_iterator &it,
1818
string_view::const_iterator last) {
1919
if (it != last) {
20-
if (std::isalnum(*it, std::locale("C"))) {
20+
if (std::isalnum(*it, std::locale::classic())) {
2121
++it;
2222
return true;
2323
}
@@ -28,7 +28,7 @@ inline bool isalnum(string_view::const_iterator &it,
2828
inline bool isdigit(string_view::const_iterator &it,
2929
string_view::const_iterator last) {
3030
if (it != last) {
31-
if (std::isdigit(*it, std::locale("C"))) {
31+
if (std::isdigit(*it, std::locale::classic())) {
3232
++it;
3333
return true;
3434
}
@@ -91,14 +91,14 @@ inline bool is_pct_encoded(string_view::const_iterator &it,
9191
}
9292
}
9393

94-
if (std::isxdigit(*it_copy, std::locale("C"))) {
94+
if (std::isxdigit(*it_copy, std::locale::classic())) {
9595
++it_copy;
9696
if (it_copy == last) {
9797
return false;
9898
}
9999
}
100100

101-
if (std::isxdigit(*it_copy, std::locale("C"))) {
101+
if (std::isxdigit(*it_copy, std::locale::classic())) {
102102
++it_copy;
103103
it = it_copy;
104104
return true;

0 commit comments

Comments
 (0)