Skip to content

Commit 5f78809

Browse files
committed
[stdlib] a better pointer as associated object id
1 parent 93ac3ec commit 5f78809

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

stdlib/public/core/StringGuts.swift

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -421,9 +421,11 @@ extension _StringGuts {
421421
extension _StringGuts {
422422

423423
private static var associationKey: UnsafeRawPointer {
424-
// We never dereference this, we just use this address as a unique key
425-
// TODO: perhaps use the address of a metatype instead
426-
unsafe UnsafeRawPointer(Builtin.addressof(&_swiftEmptyArrayStorage))
424+
// We never dereference this, we only use this address as a unique key
425+
unsafe unsafeBitCast(
426+
ObjectIdentifier(_StringGuts.self),
427+
to: UnsafeRawPointer.self
428+
)
427429
}
428430

429431
internal func getAssociatedStorage() -> __StringStorage? {

0 commit comments

Comments
 (0)