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 @@ -880,7 +880,7 @@ extension String {
880
880
}
881
881
}
882
882
883
- extension Sequence where Element == String {
883
+ extension Sequence where Element: StringProtocol {
884
884
885
885
/// Returns a new string by concatenating the elements of the sequence,
886
886
/// adding the given separator between each element.
@@ -914,7 +914,7 @@ extension Sequence where Element == String {
914
914
for chunk in self {
915
915
// FIXME(performance): this code assumes UTF-16 in-memory representation.
916
916
// It should be switched to low-level APIs.
917
- r += separatorSize + chunk. utf16. count
917
+ r += separatorSize + chunk. _ephemeralString . utf16. count
918
918
}
919
919
return r - separatorSize
920
920
}
@@ -925,17 +925,17 @@ extension Sequence where Element == String {
925
925
926
926
if separatorSize == 0 {
927
927
for x in self {
928
- result. append ( x)
928
+ result. append ( x. _ephemeralString )
929
929
}
930
930
return result
931
931
}
932
932
933
933
var iter = makeIterator ( )
934
934
if let first = iter. next ( ) {
935
- result. append ( first)
935
+ result. append ( first. _ephemeralString )
936
936
while let next = iter. next ( ) {
937
937
result. append ( separator)
938
- result. append ( next)
938
+ result. append ( next. _ephemeralString )
939
939
}
940
940
}
941
941
You can’t perform that action at this time.
0 commit comments