From 3732ad9c227125986e6d1efc26b826154120e65d Mon Sep 17 00:00:00 2001 From: Olivier Chafik Date: Wed, 10 Apr 2024 23:05:14 +0100 Subject: [PATCH] grammars: reserve rejects & next candidates --- llama.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/llama.cpp b/llama.cpp index b6e2ade91..a11bf78dc 100644 --- a/llama.cpp +++ b/llama.cpp @@ -11951,6 +11951,7 @@ static std::vector llama_grammar_reject_candidates_for_ const std::vector & candidates) { std::vector rejects; + rejects.reserve(candidates.size()); if (stack.empty()) { for (const auto & tok : candidates) { @@ -11964,6 +11965,8 @@ static std::vector llama_grammar_reject_candidates_for_ const llama_grammar_element * stack_pos = stack.back(); std::vector next_candidates; + next_candidates.reserve(candidates.size()); + for (const auto & tok : candidates) { if (*tok.code_points == 0) { // reached end of full codepoints in token, reject iff it ended in a partial sequence