mirror of
https://github.com/vim/vim.git
synced 2026-05-28 00:21:37 +02:00
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 <mattn.jp@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
This commit is contained in:
committed by
Christian Brabandt
parent
97a75d835b
commit
67deae3b77
+9
-2
@@ -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;
|
||||
}
|
||||
|
||||
@@ -734,6 +734,8 @@ static char *(features[]) =
|
||||
|
||||
static int included_patches[] =
|
||||
{ /* Add new patch number below this line */
|
||||
/**/
|
||||
147,
|
||||
/**/
|
||||
146,
|
||||
/**/
|
||||
|
||||
Reference in New Issue
Block a user