Problem: str2specialbuf() can be improved
Solution: Optimize str2specialbuf function in message.c
(Yasuhiro Matsumoto)
closes: #19415
Signed-off-by: Yasuhiro Matsumoto <mattn.jp@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
void
str2specialbuf(char_u *sp, char_u *buf, int len)
{
- char_u *s;
+ char_u *s;
+ size_t buf_len = 0;
+ size_t s_len;
*buf = NUL;
while (*sp)
{
- s = str2special(&sp, FALSE, FALSE);
- if ((int)(STRLEN(s) + STRLEN(buf)) < len)
- STRCAT(buf, s);
+ s = str2special(&sp, FALSE, FALSE);
+ s_len = STRLEN(s);
+ if (buf_len + s_len < (size_t)len)
+ {
+ STRCPY(buf + buf_len, s);
+ buf_len += s_len;
+ }
+ else
+ break;
}
}
static int included_patches[] =
{ /* Add new patch number below this line */
+/**/
+ 2,
/**/
1,
/**/