Skip to content

Commit

Permalink
unicode : reuse iterator (ggerganov#5726)
Browse files Browse the repository at this point in the history
  • Loading branch information
ggerganov authored Feb 26, 2024
1 parent 4804215 commit 67fd331
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion unicode.h
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 67fd331

Please sign in to comment.