dont construct new locale every time

This commit is contained in:
Douglas Hanley 2024-02-29 16:08:44 -06:00
parent 4bffc07144
commit 4a24bdfabd

View file

@ -9001,12 +9001,13 @@ struct llm_tokenizer_wpm {
} }
uint32_t to_lower(uint32_t code) { uint32_t to_lower(uint32_t code) {
static const std::locale locale("en_US.UTF-8");
#if defined(_WIN32) #if defined(_WIN32)
if (code > 0xFFFF) { if (code > 0xFFFF) {
return code; return code;
} }
#endif #endif
return std::tolower(wchar_t(code), std::locale("en_US.UTF-8")); return std::tolower(wchar_t(code), locale);
} }
bool is_ascii_punct(uint32_t code) { bool is_ascii_punct(uint32_t code) {