Commit: patch 9.2.0950: transstr() can be improved (after 9.2.0906)

3 views
Skip to first unread message

Christian Brabandt

unread,
Aug 12, 2026, 4:00:20 PM (22 hours ago) Aug 12
to vim...@googlegroups.com
patch 9.2.0950: transstr() can be improved (after 9.2.0906)

Commit: https://github.com/vim/vim/commit/fe65307d49b482ffdd4c81ce46352ee091e2c67b
Author: Hirohito Higashi <h.eas...@gmail.com>
Date: Wed Aug 12 19:47:43 2026 +0000

patch 9.2.0950: transstr() can be improved (after 9.2.0906)

Problem: transstr() has comments that do not add anything to what the
code says, and it casts a length to int only to cast it back to
size_t.
Solution: Drop the comments and keep the length in a size_t
(Hirohito Higashi).

related: #20925
closes: #21026

Co-Authored-By: Claude Opus 5 (1M context) <nor...@anthropic.com>
Signed-off-by: Hirohito Higashi <h.eas...@gmail.com>
Signed-off-by: Christian Brabandt <c...@256bit.org>

diff --git a/src/charset.c b/src/charset.c
index 3be32f5fb..8a8b930c3 100644
--- a/src/charset.c
+++ b/src/charset.c
@@ -383,8 +383,6 @@ transstr(char_u *s)
if (res == NULL)
return NULL;

- // Keep a tail pointer to append to, appending with STRCAT would make
- // this loop quadratic.
char_u *d = res;

p = s;
@@ -395,7 +393,6 @@ transstr(char_u *s)
c = (*mb_ptr2char)(p);
if (vim_isprintc(c))
{
- // append printable multi-byte char
mch_memmove(d, p, (size_t)l);
d += l;
}
@@ -409,9 +406,9 @@ transstr(char_u *s)
else
{
char_u *trs = transchar_byte(*p++);
- int trs_len = (int)STRLEN(trs);
+ size_t trs_len = STRLEN(trs);

- mch_memmove(d, trs, (size_t)trs_len);
+ mch_memmove(d, trs, trs_len);
d += trs_len;
}
}
diff --git a/src/testdir/test_functions.vim b/src/testdir/test_functions.vim
index 3aec6c524..c49d9dba0 100644
--- a/src/testdir/test_functions.vim
+++ b/src/testdir/test_functions.vim
@@ -253,7 +253,6 @@ func Test_strtrans()
call assert_equal('^A^_^?', strtrans("\x01\x1f\x7f"))
" an unprintable byte above 0x7f uses the meta notation
call assert_equal('| ', strtrans("\xa0"))
- " a printable high byte is unchanged
call assert_equal("\xe9", strtrans("\xe9"))
call assert_equal("x^B\xe9| y", strtrans("x\x02\xe9\xa0y"))
set encoding=utf-8
diff --git a/src/version.c b/src/version.c
index ffe735bba..18210eb02 100644
--- a/src/version.c
+++ b/src/version.c
@@ -763,6 +763,8 @@ static char *(features[]) =

static int included_patches[] =
{ /* Add new patch number below this line */
+/**/
+ 950,
/**/
949,
/**/
Reply all
Reply to author
Forward
0 new messages