perf(parser): remove branch from parse_modifiers#20821
perf(parser): remove branch from parse_modifiers#20821graphite-app[bot] merged 1 commit intomainfrom
parse_modifiers#20821Conversation
There was a problem hiding this comment.
Pull request overview
This PR applies a small hot-path optimization in the parser’s modifier parsing by removing a dedicated has_seen_static_modifier tracking branch and relying on the existing ModifierKinds bitfield already stored in Modifiers.
Changes:
- Remove
has_seen_static_modifierfromparse_modifiers. - Pass the already-seen
ModifierKindsintotry_parse_modifierand use it to detect repeatedstatic.
Merging this PR will not alter performance
Comparing Footnotes
|
Merge activity
|
ebbdd03 to
ccbd3e9
Compare
Small perf optimization. `Modifiers` already encodes which modifiers have been seen, so there's no need to additionally track whether a `static` modifier has been seen or not in a separate variable. Remove `has_seen_static_modifier` variable from `parse_modifiers`, and the unpredictable branch which updates it, and instead do the check only when it's needed in `try_parse_modifier`. +0.1% improvement on some parser benchmarks, and CodSpeed doesn't take into account the cost of branch misprediction.
26f05f9 to
b3ca6a4
Compare
ccbd3e9 to
eb02c88
Compare
Small perf optimization. `Modifiers` already encodes which modifiers have been seen, so there's no need to additionally track whether a `static` modifier has been seen or not in a separate variable. Remove `has_seen_static_modifier` variable from `parse_modifiers`, and the unpredictable branch which updates it, and instead do the check only when it's needed in `try_parse_modifier`. +0.1% improvement on some parser benchmarks, and CodSpeed doesn't take into account the cost of branch misprediction.
b3ca6a4 to
2e7e6bd
Compare

Small perf optimization.
Modifiersalready encodes which modifiers have been seen, so there's no need to additionally track whether astaticmodifier has been seen or not in a separate variable.Remove
has_seen_static_modifiervariable fromparse_modifiers, and the unpredictable branch which updates it, and instead do the check only when it's needed intry_parse_modifier.+0.1% improvement on some parser benchmarks, and CodSpeed doesn't take into account the cost of branch misprediction.