We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 843a584 commit 2dcbc53Copy full SHA for 2dcbc53
stdlib/public/core/UnicodeHelpers.swift
@@ -397,12 +397,13 @@ extension _StringGuts {
397
}
398
399
// TODO(String performance): Stack buffer if small enough
400
- var cus = Array<UInt16>(repeating: 0, count: count)
401
- cus.withUnsafeMutableBufferPointer {
+ let cus = Array<UInt16>(unsafeUninitializedCapacity: count) {
+ buffer, initializedCapacity in
402
_cocoaStringCopyCharacters(
403
from: self._object.cocoaObject,
404
range: start..<end,
405
- into: $0.baseAddress._unsafelyUnwrappedUnchecked)
+ into: buffer.baseAddress._unsafelyUnwrappedUnchecked)
406
+ initializedCapacity = count
407
408
return cus.withUnsafeBufferPointer {
409
return Character(String._uncheckedFromUTF16($0))
0 commit comments