Conversation
This is a simple implementation with a different API from the previous code, designed to be replaced with a more efficient implementation in the future.
Most of the domain name types have been integrated with 'NameBuilder', abandoning previous support for 'from_chars()' or 'from_symbols()' and instead focusing on 'FromStr'. More complex inputs should be processed directly using 'NameBuilder' instead.
Contributor
Author
|
Closing this in favor of a |
bal-e
added a commit
that referenced
this pull request
Oct 28, 2024
Unlike the existing 'NameBuilder', this type uses a fixed-size buffer to write the name into. This results in simpler code and it should be more efficient. It provides simple methods to extract domain names by borrowing from the buffer instead of allocating. This is a rewrite of <#394>.
bal-e
added a commit
that referenced
this pull request
Oct 28, 2024
Unlike the existing 'NameBuilder', this type uses a fixed-size buffer to write the name into. This results in simpler code and it should be more efficient. It provides simple methods to extract domain names by borrowing from the buffer instead of allocating. This is a rewrite of <#394>.
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 primarily a performance enhancement. The idea is to require the storage backing
NameBuilderto always provide a fixed 256-byte array, rather than performing any dynamic allocations. SinceNameBuilders are transient objects, allocating a few more bytes won't hurt, especially if they can be put on the stack.I initially intended to make
NameBuilderjust take a reference to a[u8; 256]array somewhere in the caller's code. However, this would make it harder to storeNameBuilder(because you also need to store the backing buffer somewhere, and you can quickly run into self-referential lifetime issues). Instead, I use aBufferparameter that should implementBorrowandBorrowMut(notAsRef/AsMutas they don't have the blanketimpl Borrow<T> for T).This work will lead up to #388, making it easier to build domain names quickly. Note that I've dropped all support for
Symbolhere.