mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
[stdlib] UnsafeBufferPointer: add ".count"
In answering a forum post I noiced that I wanted this and it was missing. Also, extensive comments Also, rename the length: init parameter to count:. When writing the comments for the init function it became painfully clear why we use "count" is better than "length" especially around pointers and memory: the former is much less easy to mistake for "length in bytes". Plus it's consistent with the new ".count" property Swift SVN r20609
This commit is contained in:
@@ -153,7 +153,7 @@ public struct _ContiguousArrayBuffer<T> : _ArrayBufferType {
|
||||
func withUnsafeBufferPointer<R>(
|
||||
body: (UnsafeBufferPointer<Element>)->R
|
||||
) -> R {
|
||||
let ret = body(UnsafeBufferPointer(start: self.baseAddress, length: count))
|
||||
let ret = body(UnsafeBufferPointer(start: self.baseAddress, count: count))
|
||||
_fixLifetime(self)
|
||||
return ret
|
||||
}
|
||||
@@ -165,7 +165,7 @@ public struct _ContiguousArrayBuffer<T> : _ArrayBufferType {
|
||||
body: (UnsafeMutableBufferPointer<T>)->R
|
||||
) -> R {
|
||||
let ret = body(
|
||||
UnsafeMutableBufferPointer(start: baseAddress, length: count))
|
||||
UnsafeMutableBufferPointer(start: baseAddress, count: count))
|
||||
_fixLifetime(self)
|
||||
return ret
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user