[vim/vim] Cache string segments lengths in function exe_concat(). (PR #19647)

2 views
Skip to first unread message

John Marriott

unread,
Mar 11, 2026, 9:05:03 PM (16 hours ago) Mar 11
to vim/vim, Subscribed

Function exe_concat() uses two for loops: the first calculates the total length of the target string; the second actually builds the target string. Both of these loops call STRLEN() (the first by explicitly calling STRLEN() and the second indirectly via a call to ga_concat()).

Running the test suite on my test machine (archlinux) showed function exe_concat() was called 39,227 times. STRLEN() was called 82,902 times:
* 82,902 explicit calls in the first for loop, and
* 82,902 implicit calls (as part of ga_concat()) in the second for loop.
The most times it was called as 8.

This PR uses an array to cache the results of the first for loop's STRLEN() calls, which is then used in the second for loop by changing the call to ga_concat() to ga_concat_len().

Cheers
John


You can view, comment on, or merge this pull request online at:

  https://github.com/vim/vim/pull/19647

Commit Summary

  • 0672388 Cache string segments lengths in function .
  • 7f54467 Cache string segments lengths in function exe_concat().

File Changes

(1 file)

Patch Links:


Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/19647@github.com>

Reply all
Reply to author
Forward
0 new messages