Conversation
1fb012e to
814c712
Compare
Name to be more performantName to be more performant
martin-g
approved these changes
Mar 2, 2026
martin-g
reviewed
Mar 2, 2026
martin-g
reviewed
Mar 3, 2026
This is achieved by:
- Making `Name` one allocation instead of two
- Returning references as much as possible to reduce cloning
- `.namespace()` returns a `NamespaceRef<'_>` which is a `Option<&'_ str>`
- `fully_qualified_name` returns a `Cow<'_, Name>` which reduces allocations
when the name already has a namespace or there is enclosing namespace.
- Allow efficient construction of the name when there is an enclosing namespace
- `Display` and `fullname(None)` can now return the full name directly
This required changing the `SchemaNameValidator` trait which now needs to return
the index of the starting byte of the name. Included in this change is providing
default implementations for `*Validator::validate` functions. This allows users to
easily implement the trait by just returning a different regex.
Co-authored-by: Martin Grigorov <martin-g@users.noreply.github.com>
85050c7 to
49f770c
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This is achieved by:
Nameone allocation instead of two.namespace()returns aNamespaceRef<'_>which is aOption<&'_ str>fully_qualified_namereturns aCow<'_, Name>which reduces allocations when the name already has a namespace or there is enclosing namespace.Displayandfullname(None)can now return the full name directlyThis required changing the
SchemaNameValidatortrait which now needs to return the index of the starting byte of the name. Included in this change is providing default implementations for*Validator::validatefunctions. This allows users to easily implement the trait by just returning a different regex.Fixes #492