Skip to content

Allow users to "lock" interners, reducing memory overhead. #87

Description

@bentheiii

Hello, for our use case, we have an initial population of a StringInterner with values, and then there is a long period in which only symbol resolution is needed. To reduce memory usage during the second period, we'd like to be able to resolve interned symbols without the additional memory overhead for interning new strings.

I propose to add a new struct, which will only allow to resolve strings from a given backend

pub struct StringResolver<B>
{
    backend: B,
}

impl<B> StringResolver<B>
where
    B: Backend,
{
    pub fn resolve(&self, symbol: <B as Backend>::Symbol) -> Option<&str> {
      ...
    }

    pub unsafe fn resolve_unchecked(&self, symbol: <B as Backend>::Symbol) -> &str {
      ...
    }
}

We will also add a method to convert StringInterners to a StringResolver

impl<B, H> StringInterner<B, H>
{
    pub fn into_resolver(self)->StringResolver<B>{
      ....
   }
}

I'd be happy to make a PR for this if this is approved

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions