Skip to content

perf(lexer): faster decoding unicode escape sequences #10073

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

overlookmotel
Copy link
Contributor

@overlookmotel overlookmotel commented Mar 27, 2025

Tiny optimization to lexer.

Use peek_byte instead of peek_char, and move consuming { character in \u{ to directly after the peek_byte call, so that compiler can see that it's infallible and that the next char is definitely ASCII.

Copy link
Contributor Author

overlookmotel commented Mar 27, 2025


How to use the Graphite Merge Queue

Add either label to this PR to merge it via the merge queue:

  • 0-merge - adds this PR to the back of the merge queue
  • hotfix - for urgent hot fixes, skip the queue and merge this PR next

You must have a Graphite account in order to use the merge queue. Sign up using this link.

An organization admin has enabled the Graphite Merge Queue in this repository.

Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue.

This stack of pull requests is managed by Graphite. Learn more about stacking.

@overlookmotel overlookmotel marked this pull request as ready for review March 27, 2025 07:29
@github-actions github-actions bot added A-parser Area - Parser C-performance Category - Solution not expected to change functional behavior, only performance labels Mar 27, 2025
@overlookmotel overlookmotel changed the base branch from 03-27-refactor_lexer_shorten_code_for_parsing_hex_digit to graphite-base/10073 March 27, 2025 07:44
@overlookmotel overlookmotel force-pushed the 03-27-perf_lexer_faster_decoding_unicode_escape_sequences branch from 68f53e0 to 0dd2425 Compare March 27, 2025 07:44
@overlookmotel overlookmotel changed the base branch from graphite-base/10073 to 03-27-refactor_lexer_shorten_code_for_parsing_hex_digit March 27, 2025 07:44
Copy link

codspeed-hq bot commented Mar 27, 2025

CodSpeed Instrumentation Performance Report

Merging #10073 will not alter performance

Comparing 03-27-perf_lexer_faster_decoding_unicode_escape_sequences (59b855f) with 03-27-refactor_lexer_shorten_code_for_parsing_hex_digit (630e189)

Summary

✅ 30 untouched benchmarks
🆕 3 new benchmarks

Benchmarks breakdown

Benchmark BASE HEAD Change
🆕 linter[RadixUIAdoptionSection.jsx] N/A 2.7 ms N/A
🆕 linter[cal.com.tsx] N/A 1.2 s N/A
🆕 linter[checker.ts] N/A 3 s N/A

@Boshen Boshen added the 0-merge Merge with Graphite Merge Queue label Mar 27, 2025
Copy link
Member

Boshen commented Mar 27, 2025

Merge activity

  • Mar 27, 5:01 AM EDT: The merge label '0-merge' was detected. This PR will be added to the Graphite merge queue once it meets the requirements.
  • Mar 28, 12:24 AM EDT: Boshen added this pull request to the Graphite merge queue.
  • Mar 28, 1:08 AM EDT: A user merged this pull request with the Graphite merge queue.

Tiny optimization to lexer.

Use `peek_byte` instead of `peek_char`, and move consuming `{` character in `\u{` to directly after the `peek_byte` call, so that compiler can see that it's infallible and that the next char is definitely ASCII.
@graphite-app graphite-app bot force-pushed the 03-27-refactor_lexer_shorten_code_for_parsing_hex_digit branch from 722b630 to 630e189 Compare March 28, 2025 04:32
@graphite-app graphite-app bot force-pushed the 03-27-perf_lexer_faster_decoding_unicode_escape_sequences branch from 0dd2425 to 59b855f Compare March 28, 2025 04:33
@graphite-app graphite-app bot removed the 0-merge Merge with Graphite Merge Queue label Mar 28, 2025
Base automatically changed from 03-27-refactor_lexer_shorten_code_for_parsing_hex_digit to main March 28, 2025 05:06
@graphite-app graphite-app bot merged commit 59b855f into main Mar 28, 2025
27 checks passed
@graphite-app graphite-app bot deleted the 03-27-perf_lexer_faster_decoding_unicode_escape_sequences branch March 28, 2025 05:08
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