Repository navigation
Conversation
Throwing Swift methods that return Swift values, such as strings, arrays and structs, now pass the successful value to a SwiftResultConsumer while Swift still owns it. Before, C++ called tryMakeSwiftValue(), which returned T?, and C++ allocated a box for that swift::Optional<T> on every successful call.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
…d-swift-method-results
This branch was successfully deployed
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.
Stacked on #1991.
Throwing Swift methods that return a Swift value now lend it to a
SwiftResultConsumerwhile Swift still owns it. Before, Swift wrote the value into storage that C++ read back throughtryMakeSwiftValue<T>(), which returned aswift::Optional<T>, and C++ allocated and freed a box for it on every successful call.Methods returning
void, primitives, classes or imported C++ values keep their current bridges, and so do non-throwing methods and Swift callbacks.SwiftResultConsumerTypeis aSwiftPointerType, like the other pointer adapters.Before the rebase onto current v1, I measured this in a local Release Hermes harness on the iOS simulator. Concatenating
"hello"and"world"went from 151 ns to 97 ns per call, and two 32-character strings from 303 ns to 247 ns. The harness lives outside the repo, and I haven't run the benchmark app.The standalone iOS suite passes. Android is unaffected because only Apple bridge code changed.
🤖 Generated with Claude Code