-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Use interned symbols instead of strings in more places #14840
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
Use interned symbols instead of strings in more places #14840
Conversation
124cab7
to
e422ed7
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All the symbol changes look ok. Just notes on the formatting code.
clippy_dev/src/fmt.rs
Outdated
} | ||
|
||
/// Format the symbols list | ||
fn fmt_syms(check: bool) -> Result<(), Error> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you switch this to use uitils::FileUpdater
. Would be something like
FileUpdater::default().update_file_checked(
"clippy dev fmt",
mode,
path,
update_text_region_fn("start", "end", |dst| write_dst),
)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't know FileUpdater
, nice!
clippy_dev/src/fmt.rs
Outdated
line.strip_suffix(',').unwrap_or(line).trim_end() | ||
}) | ||
.collect::<Vec<_>>(); | ||
lines.sort_by_cached_key(|a| a.to_uppercase()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Given that the order doesn't really matter, only that there is one, I would just sort normally. x.py tidy
also sorts via a normal comparison.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
e422ed7
to
16087ca
Compare
This comment has been minimized.
This comment has been minimized.
16087ca
to
e16801e
Compare
Rebased |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you.
This patch series makes heavy use of interned symbols when matching against known method names:
clippy_utils::sym
clippy dev fmt
/clippy dev fmt --check
The symbols are kept as-is (not rendered as strings) as much as possible to avoid needing locking the interner as much as possible. Static strings have been kept when they are only used when emitting a diagnostic, as there is no benefit in using interned strings for de-interning them right after.
changelog: none
r? @Alexendoo