diff --git a/examples/lookup-static/lookup-static.cpp b/examples/lookup-static/lookup-static.cpp index e3d56e49c..afdb56ebb 100644 --- a/examples/lookup-static/lookup-static.cpp +++ b/examples/lookup-static/lookup-static.cpp @@ -77,19 +77,16 @@ int main(int argc, char ** argv){ const llama_token value = inp_static[i + 2]; auto frequency_it = hashmap.find(key); - std::unordered_map frequency; if (frequency_it != hashmap.end()) { - frequency = frequency_it->second; - } - - auto token_it = frequency.find(value); - if (token_it != frequency.end()) { - token_it->second++; + auto token_it = frequency_it->second.find(value); + if (token_it != frequency_it->second.end()) { + token_it->second++; + } else { + frequency_it->second.emplace(std::make_pair(value, 1)); + } } else { + std::unordered_map frequency; frequency.emplace(std::make_pair(value, 1)); - } - - if (frequency_it == hashmap.end()) { hashmap.emplace(std::make_pair(key, frequency)); } }