Skip to content

Commit 35502ef

Browse files
committed
[stdlib] Acknowledge there are no spare bits in Set/Dictionary’s BridgeObject storage
We really need to do a pass on the _BridgeStorage API at some point soon.
1 parent bb2cb06 commit 35502ef

File tree

2 files changed

+11
-8
lines changed

2 files changed

+11
-8
lines changed

stdlib/public/core/DictionaryVariant.swift

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -78,26 +78,28 @@ extension Dictionary._Variant {
7878

7979
@inlinable
8080
internal mutating func isUniquelyReferenced() -> Bool {
81-
return object.isUniquelyReferencedNative()
81+
return object.isUniquelyReferenced_native_noSpareBits()
8282
}
8383

8484
#if _runtime(_ObjC)
8585
@usableFromInline @_transparent
8686
internal var isNative: Bool {
87-
return guaranteedNative || object.isNative
87+
if guaranteedNative { return true }
88+
return object.isNativeWithClearedSpareBits(0)
8889
}
8990
#endif
9091

9192
@usableFromInline @_transparent
9293
internal var asNative: _NativeDictionary<Key, Value> {
9394
get {
94-
return _NativeDictionary<Key, Value>(object.nativeInstance)
95+
return _NativeDictionary<Key, Value>(object.nativeInstance_noSpareBits)
9596
}
9697
set {
9798
self = .init(native: newValue)
9899
}
99100
_modify {
100-
var native = _NativeDictionary<Key, Value>(object.nativeInstance)
101+
var native = _NativeDictionary<Key, Value>(
102+
object.nativeInstance_noSpareBits)
101103
self = .init(dummy: ())
102104
yield &native
103105
object = .init(native: native._storage)

stdlib/public/core/SetVariant.swift

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -75,26 +75,27 @@ extension Set._Variant {
7575

7676
@inlinable
7777
internal mutating func isUniquelyReferenced() -> Bool {
78-
return object.isUniquelyReferencedNative()
78+
return object.isUniquelyReferenced_native_noSpareBits()
7979
}
8080

8181
#if _runtime(_ObjC)
8282
@usableFromInline @_transparent
8383
internal var isNative: Bool {
84-
return guaranteedNative || object.isNative
84+
if guaranteedNative { return true }
85+
return object.isNativeWithClearedSpareBits(0)
8586
}
8687
#endif
8788

8889
@usableFromInline @_transparent
8990
internal var asNative: _NativeSet<Element> {
9091
get {
91-
return _NativeSet(object.nativeInstance)
92+
return _NativeSet(object.nativeInstance_noSpareBits)
9293
}
9394
set {
9495
self = .init(native: newValue)
9596
}
9697
_modify {
97-
var native = _NativeSet<Element>(object.nativeInstance)
98+
var native = _NativeSet<Element>(object.nativeInstance_noSpareBits)
9899
self = .init(dummy: ())
99100
yield &native
100101
object = .init(native: native._storage)

0 commit comments

Comments
 (0)