From: Haiyue Wang Date: Tue, 18 Nov 2025 17:58:22 +0000 (+0800) Subject: vocab : call reserve() for building plamo-2-translate suffix (#17343) X-Git-Tag: upstream/0.0.7446~348 X-Git-Url: https://git.djapps.eu/?a=commitdiff_plain;h=a045492088dd105231cc5f8bfaae2d527ce47344;p=pkg%2Fggml%2Fsources%2Fllama.cpp vocab : call reserve() for building plamo-2-translate suffix (#17343) Test 'Q4_K_M' quantization on https://huggingface.co/pfnet/plamo-2-translate The 'suffix_to_score' size is 193510, it needs 19 memory allocation with final capacity 262144 to hold the value, if not preserve the memory. Signed-off-by: Haiyue Wang --- diff --git a/src/llama-vocab.cpp b/src/llama-vocab.cpp index 29e31cec..a73c4c44 100644 --- a/src/llama-vocab.cpp +++ b/src/llama-vocab.cpp @@ -1281,6 +1281,7 @@ struct llm_tokenizer_plamo2 : llm_tokenizer { // Build suffix list in lexicographical order of reversed strings std::vector suffixes; + suffixes.reserve(suffix_to_score.size() + 1); for (const auto & pair : suffix_to_score) { suffixes.push_back(pair.first); }