diff --git a/stdlib/public/core/String.swift b/stdlib/public/core/String.swift index 016ad6af73e..9fc177a8ce9 100644 --- a/stdlib/public/core/String.swift +++ b/stdlib/public/core/String.swift @@ -1011,24 +1011,7 @@ extension String { /// - Parameter other: Another string. @_inlineable // FIXME(sil-serialize-all) public mutating func append(_ other: String) { - if self._guts._isEmptySingleton { - // We must be careful not to discard any capacity that - // may have been reserved for the append -- this is why - // we check for the empty string singleton rather than - // a zero `count` above. - self = other - return - } - defer { _fixLifetime(other) } - if _slowPath(other._guts._isOpaque) { - self._guts.append(other._guts._asOpaque()) - return - } - if other._guts.isASCII { - self._guts.append(other._guts._unmanagedASCIIView) - return - } - self._guts.append(other._guts._unmanagedUTF16View) + self._guts.append(other._guts) } /// Appends the given Unicode scalar to the string. diff --git a/stdlib/public/core/StringGuts.swift b/stdlib/public/core/StringGuts.swift index 96804d57883..5d8000ba6d2 100644 --- a/stdlib/public/core/StringGuts.swift +++ b/stdlib/public/core/StringGuts.swift @@ -1006,10 +1006,16 @@ extension _StringGuts { @_inlineable public // TODO(StringGuts): for testing only mutating func append(_ other: _StringGuts) { - if _isEmptySingleton { + // FIXME(TODO: JIRA): shouldn't _isEmptySingleton be sufficient? + if _isEmptySingleton || self.count == 0 && !_object.isNative { + // We must be careful not to discard any capacity that + // may have been reserved for the append -- this is why + // we check for the empty string singleton rather than + // a zero `count` above. self = other return } + defer { _fixLifetime(other) } if _slowPath(other._isOpaque) { self.append(other._asOpaque())