mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
Merge pull request #11157 from airspeedswift/stringprotocolify
[stdlib] Switch Int/Float inits + join to be on StringProtocol
This commit is contained in:
@@ -873,7 +873,7 @@ extension String {
|
||||
}
|
||||
}
|
||||
|
||||
extension Sequence where Element == String {
|
||||
extension Sequence where Element: StringProtocol {
|
||||
|
||||
/// Returns a new string by concatenating the elements of the sequence,
|
||||
/// adding the given separator between each element.
|
||||
@@ -907,7 +907,7 @@ extension Sequence where Element == String {
|
||||
for chunk in self {
|
||||
// FIXME(performance): this code assumes UTF-16 in-memory representation.
|
||||
// It should be switched to low-level APIs.
|
||||
r += separatorSize + chunk.utf16.count
|
||||
r += separatorSize + chunk._ephemeralString.utf16.count
|
||||
}
|
||||
return r - separatorSize
|
||||
}
|
||||
@@ -918,17 +918,17 @@ extension Sequence where Element == String {
|
||||
|
||||
if separatorSize == 0 {
|
||||
for x in self {
|
||||
result.append(x)
|
||||
result.append(x._ephemeralString)
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
var iter = makeIterator()
|
||||
if let first = iter.next() {
|
||||
result.append(first)
|
||||
result.append(first._ephemeralString)
|
||||
while let next = iter.next() {
|
||||
result.append(separator)
|
||||
result.append(next)
|
||||
result.append(next._ephemeralString)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user