Skip to content

Commit ae15cfb

Browse files
committed
Fix some infinite init recursion
1 parent 7f8b6a1 commit ae15cfb

File tree

3 files changed

+4
-17
lines changed

3 files changed

+4
-17
lines changed

stdlib/public/core/StringGuts.swift

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -70,15 +70,6 @@ extension _StringGuts {
7070
}
7171

7272
internal init(_ storage: _SharedStringStorage) {
73-
// TODO(UTF8 perf): Is it better, or worse, to throw the object away if
74-
// immortal? We could avoid having to ARC the object itself when owner is
75-
// nil, at the cost of repeatedly creating a new one when this string is
76-
// bridged back-and-forth to ObjC. For now, we're choosing to keep the
77-
// object allocation, perform some ARC, and require a dependent load for
78-
// literals that have bridged back in from ObjC. Long term, we will likely
79-
// emit some kind of "immortal" object for literals with efficient bridging
80-
// anyways, so this may be a short-term decision.
81-
8273
// TODO(UTF8): We should probably store perf flags in the object
8374
self.init(_StringObject(storage, isASCII: false))
8475
}

stdlib/public/core/StringRangeReplaceableCollection.swift

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -56,11 +56,7 @@ extension String: RangeReplaceableCollection {
5656
public init<S : Sequence & LosslessStringConvertible>(_ other: S)
5757
where S.Element == Character {
5858
if let str = other as? String {
59-
self.init(str)
60-
return
61-
}
62-
if let subStr = other as? Substring {
63-
self.init(subStr)
59+
self = str
6460
return
6561
}
6662
self = other.description
@@ -87,7 +83,7 @@ extension String: RangeReplaceableCollection {
8783
public init<S : Sequence>(_ characters: S)
8884
where S.Iterator.Element == Character {
8985
if let str = characters as? String {
90-
self.init(str)
86+
self = str
9187
return
9288
}
9389
if let subStr = characters as? Substring {

stdlib/public/core/Substring.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -723,11 +723,11 @@ extension Substring : RangeReplaceableCollection {
723723
public init<S : Sequence>(_ elements: S)
724724
where S.Element == Character {
725725
if let str = elements as? String {
726-
self.init(str)
726+
self = str[...]
727727
return
728728
}
729729
if let subStr = elements as? Substring {
730-
self.init(subStr)
730+
self = subStr
731731
return
732732
}
733733
self = String(elements)[...]

0 commit comments

Comments
 (0)