[vim/vim] Speed up byte searches with strchr (PR #21240)

6 views
Skip to first unread message

mattn

unread,
Sep 7, 2026, 1:29:01 AM (5 days ago) Sep 7
to vim/vim, Subscribed

Replace the byte-by-byte scan in vim_strbyte() with strchr(), preserving its byte-range and NUL behavior. Add regression coverage for both regexp engines in Latin-1 and UTF-8.

Benchmark: 100 calls to match(input, 'z') on 3,000,000 x bytes, with either no match or one z appended. Times are medians of five runs on the same Linux machine with GCC -O2; before is a96c3bc1f7, after is 6c4e26fbaf.

Regexp engine Match position Before (ms) After (ms) Speedup
1 Absent 260.865 29.894 8.73x
1 End 224.975 28.697 7.84x
2 Absent 210.428 29.356 7.17x
2 End 165.721 28.718 5.77x

Validation: build passed without new warnings; test_regexp_latin (34 tests), test_regexp_utf8 (25 tests), and the Vim9 escape, fnameescape, and shellescape tests passed. Speedups are specific to this benchmark and libc implementation.


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

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

Commit Summary

  • 6c4e26f Speed up byte searches with strchr

File Changes

(2 files)

Patch Links:


Reply to this email directly, view it on GitHub, or unsubscribe.
Triage notifications, keep track of coding agent tasks and review pull requests on the go with GitHub Mobile for iOS and Android. Download it today!
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/21240@github.com>

Christian Brabandt

unread,
Sep 7, 2026, 4:11:20 PM (4 days ago) Sep 7
to vim/vim, Subscribed
chrisbra left a comment (vim/vim#21240)

thanks


Reply to this email directly, view it on GitHub, or unsubscribe.
Triage notifications, keep track of coding agent tasks and review pull requests on the go with GitHub Mobile for iOS and Android. Download it today!

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/21240/c5575220004@github.com>

Reply all
Reply to author
Forward
0 new messages