mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
New indexing model: updated NSStringAPI
This commit is contained in:
@@ -336,14 +336,19 @@ extension String {
|
||||
// dispatching to the minimal selector for the supplied options.
|
||||
// So let's do that; the switch should compile away anyhow.
|
||||
return locale != nil ? _ns.compare(
|
||||
aString, options: mask,
|
||||
range: _toNSRange(range ?? self.characters.indices),
|
||||
locale: locale)
|
||||
aString,
|
||||
options: mask,
|
||||
range: _toNSRange(
|
||||
range ?? self.characters.startIndex..<self.characters.endIndex
|
||||
),
|
||||
locale: locale
|
||||
)
|
||||
|
||||
: range != nil ? _ns.compare(
|
||||
aString,
|
||||
options: mask,
|
||||
range: _toNSRange(range ?? self.characters.indices))
|
||||
range: _toNSRange(range!)
|
||||
)
|
||||
|
||||
: !mask.isEmpty ? _ns.compare(aString, options: mask)
|
||||
|
||||
@@ -1185,8 +1190,13 @@ extension String {
|
||||
) -> Range<Index>? {
|
||||
return _optionalRange(
|
||||
_ns.rangeOfCharacter(
|
||||
from: aSet, options: mask,
|
||||
range: _toNSRange(aRange ?? self.characters.indices)))
|
||||
from: aSet,
|
||||
options: mask,
|
||||
range: _toNSRange(
|
||||
aRange ?? self.characters.startIndex..<self.characters.endIndex
|
||||
)
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
// - (NSRange)rangeOfComposedCharacterSequenceAtIndex:(NSUInteger)anIndex
|
||||
@@ -1245,7 +1255,9 @@ extension String {
|
||||
locale != nil ? _ns.range(
|
||||
of: aString,
|
||||
options: mask,
|
||||
range: _toNSRange(searchRange ?? self.characters.indices),
|
||||
range: _toNSRange(
|
||||
searchRange ?? self.characters.startIndex..<self.characters.endIndex
|
||||
),
|
||||
locale: locale
|
||||
)
|
||||
: searchRange != nil ? _ns.range(
|
||||
@@ -1493,7 +1505,9 @@ extension String {
|
||||
of: target,
|
||||
with: replacement,
|
||||
options: options,
|
||||
range: _toNSRange(searchRange ?? self.characters.indices)
|
||||
range: _toNSRange(
|
||||
searchRange ?? self.characters.startIndex..<self.characters.endIndex
|
||||
)
|
||||
)
|
||||
: _ns.replacingOccurrences(of: target, with: replacement)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user