Repository navigation
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub. 1 Skipped Deployment
|
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.
mrousavy
force-pushed
the
mrousavy/v1-lend-swift-method-results
branch
from
November 2, 2026 11:39
cb0c6bb to
abbb432
Compare
This branch was previously 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 returning Swift value types now lend successful results to
SwiftResultConsumer. This avoids the outerswift::Optional<T>transport box used bywithSwiftResult(). The generated bridges cover strings, arrays, optionals, enums, structs, records, variants and AnyJSON. Primitives, direct class results, imported C++ values, nonthrowing methods and callback adapters retain their existing paths.The original pre-rebase Release simulator microbenchmark measured string concatenation at 151 -> 97 ns for "hello"/"world" and 303 -> 247 ns for two 32-character strings. These are narrow measurements, not a universal speedup: the new path still copies or retains values, and generic wrapper moves can introduce extra copies and allocations.
swiftlang/swift#92970 would remove common Optional wrapper allocations upstream, but it is still open. Rebenchmark this path when Nitro's minimum Xcode contains it. The separately linked #93321 addresses duplicate generated metadata, not Optional performance.
Rebased onto current
v1and regenerated all affected workspaces, including newer unsigned and shared-callback results. Nitrogen typecheck, lint and formatting passed. The iOS runtime suite passed with 25 tests passed, zero failures and one skipped.