]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 9.2.0147: blob: concatenation can be improved v9.2.0147
authorYasuhiro Matsumoto <mattn.jp@gmail.com>
Thu, 12 Mar 2026 19:35:42 +0000 (19:35 +0000)
committerChristian Brabandt <cb@256bit.org>
Thu, 12 Mar 2026 19:35:42 +0000 (19:35 +0000)
Problem:  blob: concatenation can be improved
Solution: Use ga_grow() to allocate space once and mch_memmove() to copy
          the blob data as a single block and fall back to the previous
          byte by byte append (Yasuhiro Matsumoto).

closes: #19645

Signed-off-by: Yasuhiro Matsumoto <mattn.jp@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
src/eval.c
src/version.c

index 5f156fafa93748f8e5fcb972d39fe83f99d03d5f..551e8641cd0e7855cf74a121f8544e899a14f94a 100644 (file)
@@ -2553,8 +2553,15 @@ tv_op_blob(typval_T *tv1, typval_T *tv2, char_u *op)
     blob_T     *b2 = tv2->vval.v_blob;
     int                len = blob_len(b2);
 
-    for (int i = 0; i < len; i++)
-       ga_append(&b1->bv_ga, blob_get(b2, i));
+    if (len > 0 && ga_grow(&b1->bv_ga, len) == OK)
+    {
+       mch_memmove((char_u *)b1->bv_ga.ga_data + b1->bv_ga.ga_len,
+                   (char_u *)b2->bv_ga.ga_data, (size_t)len);
+       b1->bv_ga.ga_len += len;
+    }
+    else
+       for (int i = 0; i < len; i++)
+           (void)ga_append(&b1->bv_ga, blob_get(b2, i));
 
     return OK;
 }
index baf369ca1b56c822c2bdb3f5c3913980ceceb3ef..5b29fc0bdbe47a58f7ed92560960ce4203cd8673 100644 (file)
@@ -734,6 +734,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    147,
 /**/
     146,
 /**/