-
Notifications
You must be signed in to change notification settings - Fork 38
Pre-intern extra symbols to avoid Symbol::intern() and sym!() #398
Copy link
Copy link
Closed
Labels
A-LinterRelated to the linter and custom lintsRelated to the linter and custom lintsC-PerformanceD-ModestA "normal" level of difficulty; suitable for simple features or challenging fixesA "normal" level of difficulty; suitable for simple features or challenging fixesS-BlockedThis cannot move forward until something else changesThis cannot move forward until something else changesS-Needs-DesignThis issue requires design work to think about how it would best be accomplishedThis issue requires design work to think about how it would best be accomplished
Metadata
Metadata
Assignees
Labels
A-LinterRelated to the linter and custom lintsRelated to the linter and custom lintsC-PerformanceD-ModestA "normal" level of difficulty; suitable for simple features or challenging fixesA "normal" level of difficulty; suitable for simple features or challenging fixesS-BlockedThis cannot move forward until something else changesThis cannot move forward until something else changesS-Needs-DesignThis issue requires design work to think about how it would best be accomplishedThis issue requires design work to think about how it would best be accomplished
The Rust compiler uses string interning to optimize the storage size and comparison time of strings, however there is a performance cost anytime an interned string (represented as a
u32) is converted to and from a&str.rust-lang/rust#138682 has landed, meaning will can now set
Config::extra_symbolswith a list of strings that should be pre-interned by the compiler. We can then create these predefined symbols quickly usingSymbol::new()andPREDEFINED_SYMBOLS_COUNT, avoiding any global locks.We should use this new system to pre-intern any strings that we use in
bevy_lint. Extra thought should be put into how we design this, as the system that we use to should make it easy to add new strings in the future in a way that doesn't break existing code.