patch 9.1.1151: too many strlen() calls in getchar.c

Problem:  too many strlen() calls in getchar.c
Solution: store last inserted and recorded lengths,
          add functions to retrieve those and use those
          functions (John Marriott)

closes: #16720

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 a1224a2..6f22b43 100644
--- a/src/edit.c
+++ b/src/edit.c
@@ -421,7 +421,7 @@
 	new_insert_skip = 0;
     else
     {
-	new_insert_skip = (int)STRLEN(ptr);
+	new_insert_skip = (int)get_inserted_len();
 	vim_free(ptr);
     }
 
@@ -2462,7 +2462,7 @@
      * otherwise CTRL-O w and then <Left> will clear "last_insert".
      */
     ptr = get_inserted();
-    int added = ptr == NULL ? 0 : (int)STRLEN(ptr) - new_insert_skip;
+    int added = ptr == NULL ? 0 : (int)get_inserted_len() - new_insert_skip;
     if (did_restart_edit == 0 || added > 0)
     {
 	vim_free(last_insert);
@@ -2993,11 +2993,11 @@
 
     if (last_insert == NULL)
 	return NULL;
-    s = vim_strsave(last_insert + last_insert_skip);
+    len = (int)STRLEN(last_insert + last_insert_skip);
+    s = vim_strnsave(last_insert + last_insert_skip, len);
     if (s == NULL)
 	return NULL;
 
-    len = (int)STRLEN(s);
     if (len > 0 && s[len - 1] == ESC)	// remove trailing ESC
 	s[len - 1] = NUL;
     return s;