[clang] [Clang][Lexer][Performance] Optimize Lexer whitespace skipping logic (PR #180819)
Thibault Monnier via cfe-commits
cfe-commits at lists.llvm.org
Mon Feb 16 00:48:54 PST 2026
Thibault-Monnier wrote:
FYI, I will not be able to work more on this this week. I appreciate the remarks though.
> That said I'd like to know what the performance difference you are seeing between\n\nbool isHorizontalWhitespace(unsigned char c) {\n return c == ' ' || c == '\\t' || c == '\\f' || c == '\\v';\n}\nand\n\nwhile (LLVM_LIKELY(Char == ' ') || isHorizontalWhitespace(Char))
[Much worse cycle and instructions count]( https://llvm-compile-time-tracker.com/compare.php?from=faa899a6ce518c1176f2bf59f199eb42e59d840e&to=805b053f8003709679122a1bf639534f0defb70e&stat=cycles).
> If you look three lines below your first change you can see that there is a isVerticalWhitespace call, which checks for the remaining whitespaces.
True, I'll try combining them. However, since `\n` has to be checked separately anyway, it might not change much.
https://github.com/llvm/llvm-project/pull/180819
More information about the cfe-commits
mailing list