perf(linter): use Cell instead of RefCell#13330
Conversation
How to use the Graphite Merge QueueAdd either label to this PR to merge it via 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. |
There was a problem hiding this comment.
Pull Request Overview
This PR optimizes the linter's ContextHost struct by replacing RefCell<usize> with Cell<usize> for the current_sub_host_index field. This is a performance optimization that leverages Cell's lower overhead compared to RefCell when dealing with small Copy types.
- Replace
RefCell<usize>withCell<usize>forcurrent_sub_host_index - Update all usage patterns to use
Cell'sget()andset()methods instead ofborrow()andborrow_mut() - Refactor the
next_sub_hostmethod to use bounds checking instead of relying onOption::is_some()
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
CodSpeed Instrumentation Performance ReportMerging #13330 will not alter performanceComparing Summary
Footnotes |
Merge activity
|
Follow-on after #12724. Small perf optimization. `Cell` is cheaper than `RefCell`, because it doesn't do runtime aliasing checks. It's preferable when the contained type is small and `Copy`, as is the case here (`usize`).
56adaaf to
827fe1c
Compare

Follow-on after #12724. Small perf optimization.
Cellis cheaper thanRefCell, because it doesn't do runtime aliasing checks. It's preferable when the contained type is small andCopy, as is the case here (usize).