unicode : reuse iterator (#5726)

This commit is contained in:
Georgi Gerganov 2024-02-26 14:02:12 +02:00 committed by GitHub
parent 4804215cb8
commit 67fd33132f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -404,7 +404,8 @@ static std::unordered_map<uint32_t, int> codepoint_type_map() {
static int codepoint_type(uint32_t cp) {
static std::unordered_map<uint32_t, int> codepoint_types = codepoint_type_map();
return codepoint_types.find(cp) == codepoint_types.end() ? CODEPOINT_TYPE_UNIDENTIFIED : codepoint_types.at(cp);
const auto it = codepoint_types.find(cp);
return it == codepoint_types.end() ? CODEPOINT_TYPE_UNIDENTIFIED : it->second;
}
static int codepoint_type(const std::string & utf8) {