Skip to content

Commit 561c76d

Browse files
committed
Add version of non strong ref prims that uses a closure based approach to access the value.
I am going to add a version of this that tests that Unmanaged._withUGR gives us expected performance. So we really need both versions of all of the four current benchmarks to make this truly fair.
1 parent 25233e5 commit 561c76d

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

benchmark/single-source/PrimsNonStrongRef.swift

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -628,11 +628,16 @@ protocol ValueBox : Hashable {
628628
init(_ inputValue: ValueType)
629629
var value: ValueType { get }
630630

631+
func withValue<Result>(_ f: (ValueType) throws -> Result) rethrows -> Result
631632
func free()
632633
}
633634

634635
extension ValueBox {
635636
func free() {}
637+
@_transparent
638+
func withValue<Result>(_ f: (ValueType) throws -> Result) rethrows -> Result {
639+
return try f(value)
640+
}
636641
}
637642

638643
protocol GraphNode {

0 commit comments

Comments
 (0)