patch 9.1.1137: ins_str() is inefficient by calling STRLEN()
Problem: ins_str() is inefficient by calling STRLLEN()
Solution: refactor ins_str() to take a length argument
and let all callers provide the correct length
when calling ins_str() (John Marriott)
closes: #16711
Signed-off-by: John Marriott <basilisk@internode.on.net>
Signed-off-by: Christian Brabandt <cb@256bit.org>
diff --git a/src/edit.c b/src/edit.c
index 8ad5a66..a1224a2 100644
--- a/src/edit.c
+++ b/src/edit.c
@@ -2058,7 +2058,7 @@
if (stop_arrow() == FAIL)
return;
p[len - 1] = NUL;
- ins_str(p);
+ ins_str(p, len - 1);
AppendToRedobuffLit(p, -1);
ctrlv = FALSE;
}
@@ -2275,7 +2275,7 @@
do_digraph(buf[i-1]); // may be the start of a digraph
#endif
buf[i] = NUL;
- ins_str(buf);
+ ins_str(buf, i);
if (flags & INSCHAR_CTRLV)
{
redo_literal(*buf);
@@ -4300,7 +4300,7 @@
ins_char(' ');
else
{
- ins_str((char_u *)" ");
+ ins_str((char_u *)" ", 1);
if ((State & REPLACE_FLAG))
replace_push(NUL);
}
@@ -4976,7 +4976,7 @@
ins_char(' ');
else
{
- ins_str((char_u *)" ");
+ ins_str((char_u *)" ", 1);
if (State & REPLACE_FLAG) // no char replaced
replace_push(NUL);
}