Remove unnecessary CString allocation when loading functions#379
Merged
MaikKlein merged 1 commit intoash-rs:masterfrom Mar 1, 2021
Merged
Remove unnecessary CString allocation when loading functions#379MaikKlein merged 1 commit intoash-rs:masterfrom
MaikKlein merged 1 commit intoash-rs:masterfrom
Conversation
Ralith
approved these changes
Mar 1, 2021
Collaborator
Ralith
left a comment
There was a problem hiding this comment.
I, for one, am a fan of not having completely pointless mallocs even if it's off a hotpath, at least when the complexity impact is insignificant.
CString::new needs to perform an allocation to own the `&'static str` and append a NULL byte to it. We can instead perform this "allocation" in the generator and emit a byte-string literal with trailing NULL byte that can immediately be used by the function loader.
Collaborator
Author
|
@Ralith Same thought here. It doesn't bring us much closer to |
MaikKlein
approved these changes
Mar 1, 2021
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.
CString::new needs to perform an allocation to own the
&'static strand append a NULL byte to it. We can instead perform this "allocation" in the generator and emit a byte-string literal with trailing NULL byte that can immediately be used by the function loader.Note this is just a local test I wrote up. Not sure if it should go in butIt might be beneficial towards all the embedded questions/issues where such allocations are out of the question.