Skip to content

Pre-intern extra symbols to avoid Symbol::intern() and sym!() #398

@BD103

Description

@BD103

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_symbols with a list of strings that should be pre-interned by the compiler. We can then create these predefined symbols quickly using Symbol::new() and PREDEFINED_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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-LinterRelated to the linter and custom lintsC-PerformanceD-ModestA "normal" level of difficulty; suitable for simple features or challenging fixesS-BlockedThis cannot move forward until something else changesS-Needs-DesignThis issue requires design work to think about how it would best be accomplished

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions