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

Add interner lifetime and improve documentation #76

Draft
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

Caellian
Copy link

@Caellian Caellian commented Nov 19, 2024

This commit adds 'i lifetime that can be used by backends to return &'i str when it's known that the backing string storage won't be moved.

This is the case for fixed capacity pool-like backends and backends which avoid backing buffer moves via double indirection.

StringInterner::resolve can now return &'i str for backends that support it, or a local (call-site bound) reference. The local reference prevents insertions into StringInterner due to XOR mutability, while &'i str doesn't.

This is related to #75.

TODO

This commit adds 'i lifetime that can be used by backends to return &'i
str when it's known that the backing string storage won't be moved.

This is the case for fixed capacity pool-like backends and backends
which avoid backing buffer moves via double indirection.

Signed-off-by: Tin Švagelj <[email protected]>
Signed-off-by: Tin Švagelj <[email protected]>
@Caellian Caellian changed the title Add interner lifetime Add interner lifetime and improve documentation Nov 21, 2024
@Caellian
Copy link
Author

Caellian commented Nov 21, 2024

New comparison table looks like:

light

light theme look of comparison table

dark

dark theme look of comparison table

ayu

ayu theme look of comparison table

I've also described how each backend actually works - until now I believed StringBackend and BufferBackend are identical except BufferBackend uses Vec<u8>, I think this illustrates well that these details were missing.

@Caellian
Copy link
Author

Something I didn't foresee while creating this PR is that BucketBackend is effectively a backend which doesn't have to move its contents. It's currently implemented using Strings which prevent it from handling that properly so I'll improve it as well in this PR just so it doesn't merely break the API with no benefits.

- Move comparison table to a separate section.
- Use CSS icons to make table more readable.
- Refer to the table from backend documentations.
- Explain how backends store and manipulate interned data.

Signed-off-by: Tin Švagelj <[email protected]>
Signed-off-by: Tin Švagelj <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant