diff options
author | Bram Moolenaar <Bram@vim.org> | 2021-06-04 19:17:07 +0200 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2021-06-04 19:17:07 +0200 |
commit | 6c4c404c580fadd69e39297a6cb4b214f2fcb6d6 (patch) | |
tree | 4fd835215e5589a5cebc118a63c0d46e8a81c18d | |
parent | 24951a67c24e75ec4ff7506f8e2e789ccd786e89 (diff) | |
download | vim-git-6c4c404c580fadd69e39297a6cb4b214f2fcb6d6.tar.gz |
patch 8.2.2935: calculating register width is not always neededv8.2.2935
Problem: Calculating register width is not always needed. (Christian
Brabandt)
Solution: Only calculate the width when the type is MBLOCK.
-rw-r--r-- | src/register.c | 20 | ||||
-rw-r--r-- | src/version.c | 2 |
2 files changed, 14 insertions, 8 deletions
diff --git a/src/register.c b/src/register.c index 8c951b7ea..5dc8f2896 100644 --- a/src/register.c +++ b/src/register.c @@ -2836,7 +2836,6 @@ str_to_reg( char_u **ss; char_u **pp; long maxlen; - int charlen; if (y_ptr->y_array == NULL) // NULL means empty register y_ptr->y_size = 0; @@ -2895,23 +2894,28 @@ str_to_reg( { for (ss = (char_u **) str; *ss != NULL; ++ss, ++lnum) { - charlen = MB_CHARLEN(*ss); - i = (long)STRLEN(*ss); - pp[lnum] = vim_strnsave(*ss, i); - if (charlen > maxlen) - maxlen = charlen; + pp[lnum] = vim_strsave(*ss); + if (type == MBLOCK) + { + int charlen = mb_string2cells(*ss, -1); + + if (charlen > maxlen) + maxlen = charlen; + } } } else { for (start = 0; start < len + extraline; start += i + 1) { - charlen = 0; + int charlen = 0; + for (i = start; i < len; ++i) // find the end of the line { if (str[i] == '\n') break; - charlen += mb_ptr2cells_len(str + i, len - i); + if (type == MBLOCK) + charlen += mb_ptr2cells_len(str + i, len - i); } i -= start; // i is now length of line if (charlen > maxlen) diff --git a/src/version.c b/src/version.c index eab59f42e..d55bb30ce 100644 --- a/src/version.c +++ b/src/version.c @@ -751,6 +751,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 2935, +/**/ 2934, /**/ 2933, |