mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +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:
@@ -72,7 +72,7 @@ extension String : _BuiltinExtendedGraphemeClusterLiteralConvertible {
|
||||
UTF8.self,
|
||||
input: UnsafeBufferPointer(
|
||||
start: UnsafeMutablePointer<UTF8.CodeUnit>(start),
|
||||
length: Int(byteSize)))
|
||||
count: Int(byteSize)))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -122,7 +122,7 @@ extension String : _BuiltinStringLiteralConvertible {
|
||||
UTF8.self,
|
||||
input: UnsafeBufferPointer(
|
||||
start: UnsafeMutablePointer<UTF8.CodeUnit>(start),
|
||||
length: Int(byteSize)))
|
||||
count: Int(byteSize)))
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -320,7 +320,7 @@ extension String {
|
||||
) {
|
||||
resultStorage.initialize(
|
||||
String._fromWellFormedCodeUnitSequence(UTF8.self,
|
||||
input: UnsafeBufferPointer(start: start, length: utf8Count)))
|
||||
input: UnsafeBufferPointer(start: start, count: utf8Count)))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user