File tree Expand file tree Collapse file tree 1 file changed +13
-6
lines changed Expand file tree Collapse file tree 1 file changed +13
-6
lines changed Original file line number Diff line number Diff line change @@ -989,12 +989,10 @@ extension _StringGuts {
989
989
@inlinable // @testable
990
990
internal
991
991
mutating func append( _ other: _StringGuts ) {
992
- // FIXME(TODO: JIRA): shouldn't _isEmptySingleton be sufficient?
993
- if _isEmptySingleton || self . count == 0 && !_object. isNative {
994
- // We must be careful not to discard any capacity that
995
- // may have been reserved for the append -- this is why
996
- // we check for the empty string singleton rather than
997
- // a zero `count` above.
992
+ // We inline only the _isEmptySingleton check because it can often be
993
+ // proven or disproven at compile time. A full length check is often
994
+ // inconclusive.
995
+ if _isEmptySingleton {
998
996
self = other
999
997
return
1000
998
}
@@ -1004,6 +1002,15 @@ extension _StringGuts {
1004
1002
@usableFromInline
1005
1003
internal
1006
1004
mutating func _appendSlow( _ other: _StringGuts ) {
1005
+ // FIXME(TODO: JIRA): shouldn't _isEmptySingleton be sufficient?
1006
+ if self . count == 0 && !_object. isNative {
1007
+ // We must be careful not to discard any capacity that
1008
+ // may have been reserved for the append -- this is why
1009
+ // we check for the empty string singleton rather than
1010
+ // a zero `count` above.
1011
+ self = other
1012
+ return
1013
+ }
1007
1014
if _slowPath ( other. _isOpaque) {
1008
1015
_opaqueAppend ( opaqueOther: other)
1009
1016
return
You can’t perform that action at this time.
0 commit comments