From: Yasuhiro Matsumoto Date: Thu, 12 Mar 2026 19:35:42 +0000 (+0000) Subject: patch 9.2.0147: blob: concatenation can be improved X-Git-Tag: v9.2.0147^0 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=67deae3b7796341ec2ab42faf492f13daea41007;p=thirdparty%2Fvim.git 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 Signed-off-by: Christian Brabandt --- diff --git a/src/eval.c b/src/eval.c index 5f156fafa9..551e8641cd 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 baf369ca1b..5b29fc0bdb 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, /**/