File tree Expand file tree Collapse file tree 2 files changed +8
-19
lines changed Expand file tree Collapse file tree 2 files changed +8
-19
lines changed Original file line number Diff line number Diff line change @@ -1011,24 +1011,7 @@ extension String {
1011
1011
/// - Parameter other: Another string.
1012
1012
@_inlineable // FIXME(sil-serialize-all)
1013
1013
public mutating func append( _ other: String ) {
1014
- if self . _guts. _isEmptySingleton {
1015
- // We must be careful not to discard any capacity that
1016
- // may have been reserved for the append -- this is why
1017
- // we check for the empty string singleton rather than
1018
- // a zero `count` above.
1019
- self = other
1020
- return
1021
- }
1022
- defer { _fixLifetime ( other) }
1023
- if _slowPath ( other. _guts. _isOpaque) {
1024
- self . _guts. append ( other. _guts. _asOpaque ( ) )
1025
- return
1026
- }
1027
- if other. _guts. isASCII {
1028
- self . _guts. append ( other. _guts. _unmanagedASCIIView)
1029
- return
1030
- }
1031
- self . _guts. append ( other. _guts. _unmanagedUTF16View)
1014
+ self . _guts. append ( other. _guts)
1032
1015
}
1033
1016
1034
1017
/// Appends the given Unicode scalar to the string.
Original file line number Diff line number Diff line change @@ -1006,10 +1006,16 @@ extension _StringGuts {
1006
1006
@_inlineable
1007
1007
public // TODO(StringGuts): for testing only
1008
1008
mutating func append( _ other: _StringGuts ) {
1009
- if _isEmptySingleton {
1009
+ // FIXME(TODO: JIRA): shouldn't _isEmptySingleton be sufficient?
1010
+ if _isEmptySingleton || self . count == 0 && !_object. isNative {
1011
+ // We must be careful not to discard any capacity that
1012
+ // may have been reserved for the append -- this is why
1013
+ // we check for the empty string singleton rather than
1014
+ // a zero `count` above.
1010
1015
self = other
1011
1016
return
1012
1017
}
1018
+
1013
1019
defer { _fixLifetime ( other) }
1014
1020
if _slowPath ( other. _isOpaque) {
1015
1021
self . append ( other. _asOpaque ( ) )
You can’t perform that action at this time.
0 commit comments