@@ -1107,6 +1107,7 @@ struct llama_mmap {
11071107
11081108        //  update the list of mapped fragments to avoid unmapping the same range again in the destructor
11091109        std::vector<std::pair<size_t , size_t >> new_mapped_fragments;
1110+         new_mapped_fragments.reserve (mapped_fragments.size ());
11101111        for  (const  auto  & frag : mapped_fragments) {
11111112            if  (frag.first  < first && frag.second  > last) {
11121113                //  the range is in the middle of the fragment, split it
@@ -7908,6 +7909,7 @@ struct llm_tokenizer_spm {
79087909        //  split string into utf8 chars
79097910        int  index = 0 ;
79107911        size_t  offs = 0 ;
7912+         symbols.reserve (text.size ());
79117913        while  (offs < text.size ()) {
79127914            llm_symbol sym;
79137915            size_t  len = utf8_len (text[offs]);
@@ -8065,6 +8067,7 @@ struct llm_tokenizer_bpe {
80658067            int  index = 0 ;
80668068            size_t  offset = 0 ;
80678069
8070+             symbols.reserve (word.size ());
80688071            while  (offset < word.size ()) {
80698072                llm_symbol sym;
80708073                size_t  char_len = std::min (word.size () - offset, (size_t ) ::utf8_len (word[offset]));
@@ -8138,6 +8141,7 @@ struct llm_tokenizer_bpe {
81388141                const  auto  token = vocab.token_to_id .find (str);
81398142
81408143                if  (token == vocab.token_to_id .end ()) {
8144+                     output.reserve (str.end () - str.begin ());
81418145                    for  (auto  j = str.begin (); j != str.end (); ++j) {
81428146                        std::string byte_str (1 , *j);
81438147                        auto  token_multibyte = vocab.token_to_id .find (byte_str);
@@ -8309,6 +8313,7 @@ struct llm_tokenizer_bpe {
83098313            }
83108314        }
83118315
8316+         bpe_encoded_words.reserve (bpe_words.size ());
83128317        for  (std::string & word : bpe_words) {
83138318            std::string encoded_token = " "  ;
83148319            for  (char  & c : word) {
@@ -10194,6 +10199,7 @@ static void llama_convert_tensor_internal(
1019410199    size_t  in_buff_offs = 0 ;
1019510200    size_t  out_buff_offs = 0 ;
1019610201
10202+     workers.reserve (nthread);
1019710203    for  (int  tnum = 0 ; tnum < nthread; tnum++) {
1019810204        size_t  thr_blocks = blocks_per_thread + (tnum == nthread - 1  ? spare_blocks : 0 ); //  num blocks for this thread
1019910205        size_t  thr_elems = thr_blocks * block_size; //  number of elements for this thread
@@ -10697,6 +10703,7 @@ static void llama_model_quantize_internal(const std::string & fname_inp, const s
1069710703                                first_row * n_per_row, this_nrow, n_per_row, local_hist.data (), imatrix);
1069810704                    }
1069910705                };
10706+                 workers.reserve (nthread_use - 1 );
1070010707                for  (int  it = 0 ; it < nthread_use - 1 ; ++it) {
1070110708                    workers.emplace_back (compute);
1070210709                }
0 commit comments