Skip to content

perf(parser): remove redundant checks#11207

Merged
Boshen merged 2 commits intooxc-project:mainfrom
ulrichstark:remove-redundant-checks-in-lexer
May 21, 2025
Merged

perf(parser): remove redundant checks#11207
Boshen merged 2 commits intooxc-project:mainfrom
ulrichstark:remove-redundant-checks-in-lexer

Conversation

@ulrichstark
Copy link
Contributor

@ulrichstark ulrichstark commented May 21, 2025

  1. is_number in class.rs can be removed, because is_identifier_or_keyword implies is_literal_property_name implying is_number
  2. Avoids checking for is_reserved_keyword one way and then the other way.
  3. is_all_keyword in is_identifier_or_keyword can be removed, because is_literal_property_name implies is_identifier_name implying is_all_keyword

Let's see if those changes yield any improvements in the benchmark or if the compiler was smart enough to optimize that.

Edit: removed the second change because it's not worth the sacrificed readability

@github-actions github-actions bot added A-parser Area - Parser C-performance Category - Solution not expected to change functional behavior, only performance labels May 21, 2025
@codspeed-hq
Copy link

codspeed-hq bot commented May 21, 2025

CodSpeed Instrumentation Performance Report

Merging #11207 will not alter performance

Comparing ulrichstark:remove-redundant-checks-in-lexer (281dd3c) with main (8e8dea5)

Summary

✅ 38 untouched benchmarks

@ulrichstark
Copy link
Contributor Author

ulrichstark commented May 21, 2025

Doesn't look like there are any substantial improvements. Feel free to close my PR or pick the changes you want. Two of my three changes are simple removals and make the code simpler. is_identifier was honestly more readable before I changed it, but I wanted to try it anyway for potentially better performance.

Edit: removed the second change because it's not worth the sacrificed readability

@Boshen
Copy link
Member

Boshen commented May 21, 2025

Less code is always 👍

@Boshen Boshen merged commit 14fcf89 into oxc-project:main May 21, 2025
26 checks passed
@ulrichstark ulrichstark deleted the remove-redundant-checks-in-lexer branch May 21, 2025 09:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-parser Area - Parser C-performance Category - Solution not expected to change functional behavior, only performance

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants