Forráskód Böngészése

unicode : reuse iterator (#5726)

Georgi Gerganov 1 éve
szülő
commit
67fd33132f
1 módosított fájl, 2 hozzáadás és 1 törlés
  1. 2 1
      unicode.h

+ 2 - 1
unicode.h

@@ -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) {