patch 9.2.0147: blob: concatenation can be improved
Commit:
https://github.com/vim/vim/commit/67deae3b7796341ec2ab42faf492f13daea41007
Author: Yasuhiro Matsumoto <
matt...@gmail.com>
Date: Thu Mar 12 19:35:42 2026 +0000
patch 9.2.0147: blob: concatenation can be improved
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 <
matt...@gmail.com>
Signed-off-by: Christian Brabandt <
c...@256bit.org>
diff --git a/src/eval.c b/src/eval.c
index 5f156fafa..551e8641c 100644
--- a/src/eval.c
+++ b/src/eval.c
@@ -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;
}
diff --git a/src/version.c b/src/version.c
index baf369ca1..5b29fc0bd 100644
--- a/src/version.c
+++ b/src/version.c
@@ -734,6 +734,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
+/**/
+ 147,
/**/
146,
/**/