@@ -42,26 +42,31 @@ func withClassValuePointer<Value, Result>(
42
42
of value: inout Value ,
43
43
_ body: ( UnsafeMutableRawPointer ) throws -> Result ) throws -> Result {
44
44
return try withUnsafePointer ( to: & value) {
45
- let pointer = $0. withMemoryRebound ( to: UnsafeMutableRawPointer . self, capacity: 1 ) { $0. pointee}
46
- return try body ( pointer)
45
+ return try $0. withMemoryRebound ( to: UnsafeMutableRawPointer . self, capacity: 1 ) {
46
+ try body ( $0. pointee)
47
+ }
47
48
}
48
49
}
49
50
50
51
func withExistentialValuePointer< Value, Result> (
51
52
of value: inout Value ,
52
53
_ body: ( UnsafeMutableRawPointer ) throws -> Result ) throws -> Result {
53
- return try withUnsafePointer ( to: & value) {
54
- let container = $0. withMemoryRebound ( to: ExistentialContainer . self, capacity: 1 ) { $0. pointee}
55
- let info = try metadata ( of: container. type)
56
- if info. kind == . class || info. size > ExistentialContainerBuffer . size ( ) {
57
- let base = $0. withMemoryRebound ( to: UnsafeMutableRawPointer . self, capacity: 1 ) { $0. pointee}
58
- if info. kind == . struct {
59
- return try body ( base. advanced ( by: existentialHeaderSize) )
54
+ return try withUnsafePointer ( to: & value) { ptr in
55
+ try ptr. withMemoryRebound ( to: ExistentialContainer . self, capacity: 1 ) {
56
+ let container = $0. pointee
57
+ let info = try metadata ( of: container. type)
58
+ if info. kind == . class || info. size > ExistentialContainerBuffer . size ( ) {
59
+ return try ptr. withMemoryRebound ( to: UnsafeMutableRawPointer . self, capacity: 1 ) {
60
+ let base = $0. pointee
61
+ if info. kind == . struct {
62
+ return try body ( base. advanced ( by: existentialHeaderSize) )
63
+ } else {
64
+ return try body ( base)
65
+ }
66
+ }
60
67
} else {
61
- return try body ( base )
68
+ return try body ( $0 . mutable . raw )
62
69
}
63
- } else {
64
- return try body ( $0. mutable. raw)
65
70
}
66
71
}
67
72
}
0 commit comments