Hi, Op zo 16 mrt 2025 21:00 schreef Christian Brabandt <cbli...@256bit.org>:
> patch 9.1.1212: too many strlen() calls in edit.c > > Commit: > https://github.com/vim/vim/commit/34954972c27244a4a1fb4eeeae2aa4e021efd100 > Author: John Marriott <basil...@internode.on.net> > Date: Sun Mar 16 20:49:52 2025 +0100 > > patch 9.1.1212: too many strlen() calls in edit.c > > Problem: too many strlen() calls in edit.c > Solution: refactor edit.c and remove strlen() calls > (John Marriott) > > This commit attempts to make edit.c more efficient by: > > - in truncate_spaces() pass in the length of the string. > - return a string_T from get_last_insert(), so that the length of the > string is available to the caller. > - refactor stuff_insert(): > > - replace calls to stuffReadbuff() (which calls STRLEN() on it's > string argument) with stuffReadbuffLen() (which gets the length of > it's string argument passed in). > - replace call to vim_strrchr() which searches from the start of the > string with a loop which searches from end of the string to find > the > last ESC character. > > - change get_last_insert_save() to call get_last_insert() to get the > last_insert string (the logic is in one place). > > closes: #16863 > > Signed-off-by: John Marriott <basil...@internode.on.net> > Signed-off-by: Christian Brabandt <c...@256bit.org> > > - if (len > 0 && s[len - 1] == ESC) // remove trailing ESC > - s[len - 1] = NUL; > + if (insert->length > 0) > + { > + // remove trailing ESC > + --insert->length; > + if (s[insert->length] == ESC) > + s[insert->length] = NUL; > + } > return s; > } > This looks weird. Why is the length always decremented, but the ESC only conditionally overwritten? I guess the length decrement should be inside the if statement?? Christ van Willegen > -- -- You received this message from the "vim_dev" maillist. Do not top-post! Type your reply below the text you are replying to. For more information, visit http://www.vim.org/maillist.php --- You received this message because you are subscribed to the Google Groups "vim_dev" group. To unsubscribe from this group and stop receiving emails from it, send an email to vim_dev+unsubscr...@googlegroups.com. To view this discussion visit https://groups.google.com/d/msgid/vim_dev/CA%2BOt1Owb0n28VHBYUVCAQ%3DEVjZsKX%3DgxSm7EsWGUPq5HGWdfTg%40mail.gmail.com.