Skip to content

refactor(lexer): Token::read_bool use NonNull pointer#21660

Merged
graphite-app[bot] merged 1 commit into
mainfrom
om/04-23-refactor_lexer_token_read_bool_use_nonnull_pointer
Apr 23, 2026
Merged

refactor(lexer): Token::read_bool use NonNull pointer#21660
graphite-app[bot] merged 1 commit into
mainfrom
om/04-23-refactor_lexer_token_read_bool_use_nonnull_pointer

Conversation

@overlookmotel

@overlookmotel overlookmotel commented Apr 22, 2026

Copy link
Copy Markdown
Member

Small refactor. NonNull is more ergonomic and in some cases can be more performant than raw pointers (avoids non-null check).

overlookmotel commented Apr 22, 2026

Copy link
Copy Markdown
Member Author

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 changes, fast-track this PR to the front of the merge queue

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 April 23, 2026 00:02
Copilot AI review requested due to automatic review settings April 23, 2026 00:02

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Refactors Token::read_bool in the parser lexer to use std::ptr::NonNull instead of raw pointers, aligning it with the existing NonNull-based pointer access patterns in this file and slightly simplifying the unsafe read path.

Changes:

  • Replaced ptr::from_ref(self) + raw pointer usage in Token::read_bool with NonNull::from_ref(self) and NonNull APIs.
  • Simplified the bool read by removing the unwrap_unchecked() path (since NonNull::as_ref() is infallible).
  • Removed the now-unused std::ptr import.

@codspeed-hq

codspeed-hq Bot commented Apr 23, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 48 untouched benchmarks
⏩ 3 skipped benchmarks1


Comparing om/04-23-refactor_lexer_token_read_bool_use_nonnull_pointer (81dab06) with main (2290f31)

Open in CodSpeed

Footnotes

  1. 3 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

@overlookmotel
overlookmotel force-pushed the om/04-23-perf_lexer_fix_perf_of_token_set__methods_on_rust_1.95.0 branch from f1248de to f7a428f Compare April 23, 2026 00:11
@overlookmotel
overlookmotel force-pushed the om/04-23-refactor_lexer_token_read_bool_use_nonnull_pointer branch from d3fd6bc to 605a60b Compare April 23, 2026 00:11
@overlookmotel overlookmotel self-assigned this Apr 23, 2026
@overlookmotel overlookmotel added A-parser Area - Parser C-cleanup Category - technical debt or refactoring. Solution not expected to change behavior labels Apr 23, 2026
@graphite-app
graphite-app Bot changed the base branch from om/04-23-perf_lexer_fix_perf_of_token_set__methods_on_rust_1.95.0 to graphite-base/21660 April 23, 2026 07:28
@graphite-app
graphite-app Bot force-pushed the om/04-23-refactor_lexer_token_read_bool_use_nonnull_pointer branch from 605a60b to c143e49 Compare April 23, 2026 07:35
@graphite-app
graphite-app Bot force-pushed the graphite-base/21660 branch from f7a428f to 2290f31 Compare April 23, 2026 07:35
@graphite-app
graphite-app Bot changed the base branch from graphite-base/21660 to main April 23, 2026 07:36
@graphite-app
graphite-app Bot force-pushed the om/04-23-refactor_lexer_token_read_bool_use_nonnull_pointer branch from c143e49 to 81dab06 Compare April 23, 2026 07:36
@overlookmotel overlookmotel added the 0-merge Merge with Graphite Merge Queue label Apr 23, 2026

overlookmotel commented Apr 23, 2026

Copy link
Copy Markdown
Member Author

Merge activity

Small refactor. `NonNull` is more ergonomic and in some cases can be more performant than raw pointers (avoids non-null check).
@graphite-app
graphite-app Bot force-pushed the om/04-23-refactor_lexer_token_read_bool_use_nonnull_pointer branch from 81dab06 to 0aa13eb Compare April 23, 2026 11:27
@graphite-app
graphite-app Bot merged commit 0aa13eb into main Apr 23, 2026
28 checks passed
@graphite-app graphite-app Bot removed the 0-merge Merge with Graphite Merge Queue label Apr 23, 2026
@graphite-app
graphite-app Bot deleted the om/04-23-refactor_lexer_token_read_bool_use_nonnull_pointer branch April 23, 2026 11:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-parser Area - Parser C-cleanup Category - technical debt or refactoring. Solution not expected to change behavior

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants