Add OOM test for component Func::call_async#13017
Open
fitzgen wants to merge 1 commit intobytecodealliance:mainfrom
Open
Add OOM test for component Func::call_async#13017fitzgen wants to merge 1 commit intobytecodealliance:mainfrom
Func::call_async#13017fitzgen wants to merge 1 commit intobytecodealliance:mainfrom
Conversation
Add NameMap::get_by_str to avoid infallible String allocation in component export name lookups. The NameMapNoIntern implementation allocated a String on every lookup; the new method uses borrowed &str keys directly on the underlying IndexMap instead.
ac21e79 to
f4fda42
Compare
alexcrichton
reviewed
Apr 9, 2026
Comment on lines
+143
to
+156
| impl<V> NameMap<String, V> { | ||
| /// Like [`NameMap::get`] but specialized for `String` keys to avoid | ||
| /// allocating a `String` for the lookup by using borrowed `&str` keys | ||
| /// directly on the underlying `IndexMap`. | ||
| pub fn get_by_str(&self, name: &str) -> Option<&V> { | ||
| let candidate = self.definitions.get(name); | ||
| if let Some(def) = candidate { | ||
| return Some(def); | ||
| } | ||
| let (alternate_name, _version) = alternate_lookup_key(name)?; | ||
| let (exact_key, _version) = self.alternate_lookups.get(alternate_name)?; | ||
| self.definitions.get(exact_key.as_str()) | ||
| } | ||
| } |
Member
There was a problem hiding this comment.
Given how subtle this is I'd prefer to not duplicate the get method above. Would it be possible to refactor the trait methods or un-generalize the NameMap in general if the full generic K type parameter isn't needed?
Subscribe to Label Actioncc @fitzgen DetailsThis issue or pull request has been labeled: "fuzzing", "wasmtime:api"Thus the following users have been cc'd because of the following labels:
To subscribe or unsubscribe from this label, edit the |
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.
Add NameMap::get_by_str to avoid infallible String allocation in
component export name lookups. The NameMapNoIntern implementation
allocated a String on every lookup; the new method uses borrowed
&str keys directly on the underlying IndexMap instead.
Depends on #12993