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

core: Improve ergonomics by replacing GcContext by StringContext #18105

Merged
merged 3 commits into from
Oct 2, 2024

Commits on Oct 2, 2024

  1. core: Replace GcContext by StringContext

    This is essentially still the same type, but with these differences:
    - It is explicitely intended to be used for `AvmString` manipulation
    - It is held inside `UpdateContext` instead of being created on-demand,
      making explicit 'reborrowing' methods unncessary.
    
    Note the `unsafe` lifetime extension in `PlayerBuilder::create_gc_root`,
    which is sound for mostly the same reasons as `Player::enter_arena(_mut)`
    moulins committed Oct 2, 2024
    Configuration menu
    Copy the full SHA
    a261f57 View commit details
    Browse the repository at this point in the history
  2. core: Move most of AvmStringInterner methods to StringContext

    This makes usage much simpler: `context.intern(...)` instead of
    `context.interner.intern(context.gc(), ...)`.
    
    Also make `StringContext.interner` private, as it doesn't need to be
    publicly accessible anymore.
    moulins committed Oct 2, 2024
    Configuration menu
    Copy the full SHA
    62d2b61 View commit details
    Browse the repository at this point in the history
  3. core: Minor StringContext API changes

    - Rename `get_char` to `make_char`, and `get_ascii_char` to `ascii_char`:
      this makes clearer that only `make_char` may allocate.
    - Take a `u8` instead of a `char` in `ascii_char`.
    - Take a `Range<usize>` instead of two `usize` args in `substring`.
    moulins committed Oct 2, 2024
    Configuration menu
    Copy the full SHA
    357c9fa View commit details
    Browse the repository at this point in the history