@@ -43,24 +43,6 @@ func _stdlib_binary_CFStringGetCharactersPtr(
43
43
return UnsafeMutablePointer ( mutating: _swift_stdlib_CFStringGetCharactersPtr ( source) )
44
44
}
45
45
46
- /// Bridges `source` to `Swift.String`, assuming that `source` has non-ASCII
47
- /// characters (does not apply ASCII optimizations).
48
- @inline ( never) @_semantics ( " stdlib_binary_only " ) // Hide the CF dependency
49
- func _cocoaStringToSwiftString_NonASCII(
50
- _ source: _CocoaString
51
- ) -> String {
52
- let cfImmutableValue = _stdlib_binary_CFStringCreateCopy ( source)
53
- let length = _stdlib_binary_CFStringGetLength ( cfImmutableValue)
54
- let start = _stdlib_binary_CFStringGetCharactersPtr ( cfImmutableValue)
55
-
56
- return String ( _StringCore (
57
- baseAddress: start,
58
- count: length,
59
- elementShift: 1 ,
60
- hasCocoaBuffer: true ,
61
- owner: unsafeBitCast ( cfImmutableValue, to: Optional< AnyObject> . self ) ) )
62
- }
63
-
64
46
/// Loading Foundation initializes these function variables
65
47
/// with useful values
66
48
@@ -154,30 +136,9 @@ extension String {
154
136
155
137
let length = _swift_stdlib_CFStringGetLength ( cfImmutableValue)
156
138
157
- // Look first for null-terminated ASCII
158
- // Note: the code in clownfish appears to guarantee
159
- // nul-termination, but I'm waiting for an answer from Chris Kane
160
- // about whether we can count on it for all time or not.
161
- let nulTerminatedASCII = _swift_stdlib_CFStringGetCStringPtr (
162
- cfImmutableValue, kCFStringEncodingASCII)
163
-
164
- // start will hold the base pointer of contiguous storage, if it
165
- // is found.
166
- var start : UnsafeMutableRawPointer ?
167
- let isUTF16 = ( nulTerminatedASCII == nil )
168
- if isUTF16 {
169
- let utf16Buf = _swift_stdlib_CFStringGetCharactersPtr ( cfImmutableValue)
170
- start = UnsafeMutableRawPointer ( mutating: utf16Buf)
171
- } else {
172
- start = UnsafeMutableRawPointer ( mutating: nulTerminatedASCII)
173
- }
174
-
175
139
self . _core = _StringCore (
176
- baseAddress: start,
177
- count: length,
178
- elementShift: isUTF16 ? 1 : 0 ,
179
- hasCocoaBuffer: true ,
180
- owner: cfImmutableValue)
140
+ _cocoaStringToContiguous (
141
+ source: cfImmutableValue, range: 0 ..< length, minimumCapacity: 0 ) )
181
142
}
182
143
}
183
144
0 commit comments