mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
[string] Workaround fail emptySingleton check.
This is a temporary workaround for some situations where the empty singleton is not being formed correctly (and this seems to be highly configuration dependent). Work around that for now for also checking for empty non-storage-backed Strings. This is probably too expensive a check for us to do long-term, but it works for now.
This commit is contained in:
@@ -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())
|
||||
|
||||
Reference in New Issue
Block a user