mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
[Foundation] Rework the backing storage for CharacterSet to be more performant and bridge correctly to objective-c and CF
Some cases of using isSuperset can cause crashes, this was caused by improper subclassing callouts; this pr resolves those failures (and provides unit tests for that case) The cases where the bridge was traversed too much now only causes a single bridge out call (without needing to reallocate or thrash retain/release) String.components(separatedBy: CharacterSet) should be considerably faster now not only for more apporpriate bridging calls but also no longer needing to bridge arrays back and forth. Resolves the following issues: rdar://problem/17281998 rdar://problem/26611771 rdar://problem/29738989
This commit is contained in:
@@ -14,6 +14,8 @@
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
@_exported import Foundation // Clang module
|
||||
|
||||
// Open Issues
|
||||
// ===========
|
||||
//
|
||||
@@ -391,11 +393,7 @@ extension String {
|
||||
/// Returns an array containing substrings from the `String`
|
||||
/// that have been divided by characters in a given set.
|
||||
public func components(separatedBy separator: CharacterSet) -> [String] {
|
||||
// FIXME: two steps due to <rdar://16971181>
|
||||
let nsa = _ns.components(separatedBy: separator) as NSArray
|
||||
// Since this function is effectively a bridge thunk, use the
|
||||
// bridge thunk semantics for the NSArray conversion
|
||||
return nsa as! [String]
|
||||
return _ns.components(separatedBy: separator)
|
||||
}
|
||||
|
||||
|
||||
@@ -404,10 +402,7 @@ extension String {
|
||||
/// Returns an array containing substrings from the `String`
|
||||
/// that have been divided by a given separator.
|
||||
public func components(separatedBy separator: String) -> [String] {
|
||||
let nsa = _ns.components(separatedBy: separator) as NSArray
|
||||
// Since this function is effectively a bridge thunk, use the
|
||||
// bridge thunk semantics for the NSArray conversion
|
||||
return nsa as! [String]
|
||||
return _ns.components(separatedBy: separator)
|
||||
}
|
||||
|
||||
// - (const char *)cStringUsingEncoding:(NSStringEncoding)encoding
|
||||
|
||||
Reference in New Issue
Block a user