Skip to content

Commit e5bde5c

Browse files
authored
Merge pull request #3267 from apple/stdlib-add-noescape
2 parents 680c908 + 6f86f3d commit e5bde5c

File tree

1 file changed

+9
-10
lines changed

1 file changed

+9
-10
lines changed

stdlib/public/core/ManagedBuffer.swift

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public class ManagedProtoBuffer<Value, Element> : NonObjectiveCBase {
4545
/// - Note: This pointer is only valid for the duration of the
4646
/// call to `body`.
4747
public final func withUnsafeMutablePointerToValue<R>(
48-
_ body: (UnsafeMutablePointer<Value>) -> R
48+
_ body: @noescape (UnsafeMutablePointer<Value>) -> R
4949
) -> R {
5050
return withUnsafeMutablePointers { (v, e) in return body(v) }
5151
}
@@ -56,7 +56,7 @@ public class ManagedProtoBuffer<Value, Element> : NonObjectiveCBase {
5656
/// - Note: This pointer is only valid for the duration of the
5757
/// call to `body`.
5858
public final func withUnsafeMutablePointerToElements<R>(
59-
_ body: (UnsafeMutablePointer<Element>) -> R
59+
_ body: @noescape (UnsafeMutablePointer<Element>) -> R
6060
) -> R {
6161
return withUnsafeMutablePointers { return body($0.1) }
6262
}
@@ -67,7 +67,7 @@ public class ManagedProtoBuffer<Value, Element> : NonObjectiveCBase {
6767
/// - Note: These pointers are only valid for the duration of the
6868
/// call to `body`.
6969
public final func withUnsafeMutablePointers<R>(
70-
_ body: (_: UnsafeMutablePointer<Value>, _: UnsafeMutablePointer<Element>) -> R
70+
_ body: @noescape (UnsafeMutablePointer<Value>, UnsafeMutablePointer<Element>) -> R
7171
) -> R {
7272
return ManagedBufferPointer(self).withUnsafeMutablePointers(body)
7373
}
@@ -99,7 +99,7 @@ public class ManagedBuffer<Value, Element>
9999
/// generate an initial `Value`.
100100
public final class func create(
101101
minimumCapacity: Int,
102-
initialValue: (ManagedProtoBuffer<Value, Element>) -> Value
102+
initialValue: @noescape (ManagedProtoBuffer<Value, Element>) -> Value
103103
) -> ManagedBuffer<Value, Element> {
104104

105105
let p = ManagedBufferPointer<Value, Element>(
@@ -185,7 +185,7 @@ public struct ManagedBufferPointer<Value, Element> : Equatable {
185185
public init(
186186
bufferClass: AnyClass,
187187
minimumCapacity: Int,
188-
initialValue: (buffer: AnyObject, capacity: (AnyObject) -> Int) -> Value
188+
initialValue: @noescape (buffer: AnyObject, capacity: @noescape (AnyObject) -> Int) -> Value
189189
) {
190190
self = ManagedBufferPointer(bufferClass: bufferClass, minimumCapacity: minimumCapacity)
191191

@@ -268,7 +268,7 @@ public struct ManagedBufferPointer<Value, Element> : Equatable {
268268
/// - Note: This pointer is only valid for the duration of the
269269
/// call to `body`.
270270
public func withUnsafeMutablePointerToElements<R>(
271-
_ body: (UnsafeMutablePointer<Element>) -> R
271+
_ body: @noescape (UnsafeMutablePointer<Element>) -> R
272272
) -> R {
273273
return withUnsafeMutablePointers { return body($0.1) }
274274
}
@@ -279,11 +279,10 @@ public struct ManagedBufferPointer<Value, Element> : Equatable {
279279
/// - Note: These pointers are only valid for the duration of the
280280
/// call to `body`.
281281
public func withUnsafeMutablePointers<R>(
282-
_ body: @noescape (_: UnsafeMutablePointer<Value>, _: UnsafeMutablePointer<Element>) -> R
282+
_ body: @noescape (UnsafeMutablePointer<Value>, UnsafeMutablePointer<Element>) -> R
283283
) -> R {
284-
let result = body(_valuePointer, _elementPointer)
285-
_fixLifetime(_nativeBuffer)
286-
return result
284+
defer { _fixLifetime(_nativeBuffer) }
285+
return body(_valuePointer, _elementPointer)
287286
}
288287

289288
/// Returns `true` iff `self` holds the only strong reference to its buffer.

0 commit comments

Comments
 (0)