Skip to content
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

refactor(syntax): use NonMaxU32 for IDs #4467

Merged
merged 1 commit into from
Jul 26, 2024

Commits on Jul 26, 2024

  1. refactor(syntax): use NonMaxU32 for IDs (#4467)

    `SymbolId` and `ReferenceId` are stored as `NonZeroU32`, but with a wrapper to make `u32::MAX` the illegal value, instead of `0`.
    
    Use the existing `nonmax` crate for this. Our current implementation uses `idx + 1` to avoid the zero value, whereas `nonmax` crate uses XOR `idx ^ u32::MAX`, which is a cheaper operation.
    
    Initially I made this change manually instead of pulling in a dependency, but it's a pain because it requires implementing `Debug` and `PartialOrd` by hand to handle the difference between the "actual" value and its stored representation. So I thought better to use a crate which does this for us.
    overlookmotel committed Jul 26, 2024
    Configuration menu
    Copy the full SHA
    96fc94f View commit details
    Browse the repository at this point in the history