winnow-rs / winnow

Making parsing a breeze
https://docs.rs/winnow
Other
572 stars 44 forks source link

perf(token): Allow optimizer remove branch #405

Closed epage closed 10 months ago

epage commented 10 months ago

Not entirely clear if its needed in this case but I generally have found that these const conditionals seem to provide more optimized results.

I did a rg is_partial_support -A 4 to see if any others had this problem and this seemed to be isolated.

Fixes #404

baoyachi commented 10 months ago

@epage Out of curiosity, what is 'rg is_partial_support -A 4'?

DJDuque commented 10 months ago

Out of curiosity, what is 'rg is_partial_support -A 4'?

https://github.com/BurntSushi/ripgrep

epage commented 10 months ago

We have an always-inlined function that converts the function call is_partial_supported to a monomorphized version of the parser. This makes the optimizer a lot more likely to detect code as dead and remove it, reducing binary size and improving performance.

I searched for -A4 to show me the 4 lines after the call to is_partial_supported as generally it follows a straight if/else pattern that will show up directly in the console. If it isn't so direct, the pattern can raise my attention to directly check in the source.