Problem: NFA regexp matching is slower than necessary for ASCII text
because two indirect function calls are made for every
character.
Solution: Add an inline fast path for an ASCII byte that is not followed
by a composing character.
The main loop of nfa_regmatch() fetched the current character and its byte length with two calls through the mb_ptr2char and mb_ptr2len function pointers on every character. These pointers cannot be inlined, yet for ASCII text, which is the common case, both merely return the byte and a length of one.
Handle that case inline. NUL is checked first so that reading the next byte cannot go past the end of the line, and the "next byte is ASCII" condition matches the check in utfc_ptr2len(), so a base character followed by a composing character still falls through to the original calls.
A "perf stat -e instructions" on a full scroll of a 60000 line C file with syntax highlighting enabled shows an instructions count reduction of 4%.
https://github.com/vim/vim/pull/21179
(1 file)
—
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.![]()
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.![]()