From 878c9739e13d605f9457073a49910be5b82dd309 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Fri, 13 Mar 2026 07:28:26 +0800 Subject: [PATCH] vim-patch:9.2.0147: blob: concatenation can be improved (#38276) 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: vim/vim#19645 https://github.com/vim/vim/commit/67deae3b7796341ec2ab42faf492f13daea41007 Co-authored-by: Yasuhiro Matsumoto --- src/nvim/eval/executor.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/nvim/eval/executor.c b/src/nvim/eval/executor.c index 75765e5c84..39b8df9760 100644 --- a/src/nvim/eval/executor.c +++ b/src/nvim/eval/executor.c @@ -39,8 +39,11 @@ static int tv_op_blob(typval_T *tv1, const typval_T *tv2, const char *op) blob_T *const b2 = tv2->vval.v_blob; const int len = tv_blob_len(b2); - for (int i = 0; i < len; i++) { - ga_append(&b1->bv_ga, tv_blob_get(b2, i)); + if (len > 0) { + ga_grow(&b1->bv_ga, len); + memmove((uint8_t *)b1->bv_ga.ga_data + b1->bv_ga.ga_len, + (uint8_t *)b2->bv_ga.ga_data, (size_t)len); + b1->bv_ga.ga_len += len; } return OK;