File tree Expand file tree Collapse file tree 3 files changed +9
-9
lines changed Expand file tree Collapse file tree 3 files changed +9
-9
lines changed Original file line number Diff line number Diff line change @@ -123,7 +123,7 @@ extension ${Self} : LosslessStringConvertible {
123
123
/// - Parameter text: The input string to convert to a `${Self}` instance. If
124
124
/// `text` has invalid characters or is in an invalid format, the result
125
125
/// is `nil`.
126
- public init?(_ text: String ) {
126
+ public init?<S: StringProtocol> (_ text: S ) {
127
127
let u16 = text.utf16
128
128
func parseNTBS(_ chars: UnsafePointer<CChar>) -> (${Self}, Int) {
129
129
var result: ${Self} = 0
@@ -133,7 +133,7 @@ extension ${Self} : LosslessStringConvertible {
133
133
return (result, endPtr == nil ? 0 : endPtr! - chars)
134
134
}
135
135
136
- let (result, n) = text.withCString(parseNTBS)
136
+ let (result, n) = text._ephemeralString. withCString(parseNTBS)
137
137
138
138
if n == 0 || n != u16.count
139
139
|| u16.contains(where: { $0 > 127 || _isspace_clocale($0) }) {
Original file line number Diff line number Diff line change @@ -131,10 +131,10 @@ extension FixedWidthInteger {
131
131
/// - radix: The radix, or base, to use for converting `text` to an integer
132
132
/// value. `radix` must be in the range `2...36`. The default is 10.
133
133
@_semantics ( " optimize.sil.specialize.generic.partial.never " )
134
- public init ? /* <S : StringProtocol>*/ ( _ text: String , radix: Int = 10 ) {
134
+ public init ? < S : StringProtocol > ( _ text: S , radix: Int = 10 ) {
135
135
_precondition ( 2 ... 36 ~= radix, " Radix not in range 2...36 " )
136
136
let r = Self ( radix)
137
- let s = text// ._ephemeralString
137
+ let s = text. _ephemeralString
138
138
defer { _fixLifetime ( s) }
139
139
140
140
let c = s. _core
Original file line number Diff line number Diff line change @@ -873,7 +873,7 @@ extension String {
873
873
}
874
874
}
875
875
876
- extension Sequence where Element == String {
876
+ extension Sequence where Element: StringProtocol {
877
877
878
878
/// Returns a new string by concatenating the elements of the sequence,
879
879
/// adding the given separator between each element.
@@ -907,7 +907,7 @@ extension Sequence where Element == String {
907
907
for chunk in self {
908
908
// FIXME(performance): this code assumes UTF-16 in-memory representation.
909
909
// It should be switched to low-level APIs.
910
- r += separatorSize + chunk. utf16. count
910
+ r += separatorSize + chunk. _ephemeralString . utf16. count
911
911
}
912
912
return r - separatorSize
913
913
}
@@ -918,17 +918,17 @@ extension Sequence where Element == String {
918
918
919
919
if separatorSize == 0 {
920
920
for x in self {
921
- result. append ( x)
921
+ result. append ( x. _ephemeralString )
922
922
}
923
923
return result
924
924
}
925
925
926
926
var iter = makeIterator ( )
927
927
if let first = iter. next ( ) {
928
- result. append ( first)
928
+ result. append ( first. _ephemeralString )
929
929
while let next = iter. next ( ) {
930
930
result. append ( separator)
931
- result. append ( next)
931
+ result. append ( next. _ephemeralString )
932
932
}
933
933
}
934
934
You can’t perform that action at this time.
0 commit comments