Merge pull request #11157 from airspeedswift/stringprotocolify

[stdlib] Switch Int/Float inits + join to be on StringProtocol
This commit is contained in:
Maxim Moiseev
2017-07-27 14:22:25 -07:00
committed by GitHub
3 changed files with 9 additions and 9 deletions

View File

@@ -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)
}
}