File tree Expand file tree Collapse file tree 1 file changed +4
-4
lines changed Expand file tree Collapse file tree 1 file changed +4
-4
lines changed Original file line number Diff line number Diff line change @@ -56,11 +56,11 @@ extension String: _ObjectiveCBridgeable {
56
56
result = String ( decoding: UnsafeBufferPointer ( start: conststr. _ptr, count: Int ( conststr. _length) ) , as: UTF8 . self)
57
57
} else {
58
58
let len = source. length
59
- var characters = [ unichar] ( repeating: 0 , count: len)
60
- result = characters. withUnsafeMutableBufferPointer ( ) { ( buffer: inout UnsafeMutableBufferPointer < unichar > ) -> String ? in
61
- source. getCharacters ( buffer. baseAddress!, range: NSRange ( location: 0 , length: len) )
62
- return String ( decoding: buffer, as: UTF16 . self)
59
+ let characters = [ unichar] ( unsafeUninitializedCapacity: len) { buf, initializedCount in
60
+ source. getCharacters ( buf. baseAddress!, range: NSRange ( location: 0 , length: len) )
61
+ initializedCount = len
63
62
}
63
+ result = String ( decoding: characters, as: UTF16 . self)
64
64
}
65
65
return result != nil
66
66
}
You can’t perform that action at this time.
0 commit comments