Skip to content

Commit 6f86f3d

Browse files
committed
stdlib: use defer for _fixLifetime()
1 parent e44db1e commit 6f86f3d

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

stdlib/public/core/ManagedBuffer.swift

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -281,9 +281,8 @@ public struct ManagedBufferPointer<Value, Element> : Equatable {
281281
public func withUnsafeMutablePointers<R>(
282282
_ 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)