@@ -2502,7 +2502,7 @@ final internal class _Native${Self}StorageImpl<${TypeParameters}> :
2502
2502
return BufferPointer(self)
2503
2503
}
2504
2504
2505
- // All underscored functions are unsafe and need a _fixLifetime in the caller.
2505
+ // This API is unsafe and needs a ` _fixLifetime` in the caller.
2506
2506
internal var _body: _HashedContainerStorageHeader {
2507
2507
unsafeAddress {
2508
2508
return UnsafePointer(buffer._valuePointer)
@@ -2514,32 +2514,38 @@ final internal class _Native${Self}StorageImpl<${TypeParameters}> :
2514
2514
2515
2515
@_versioned
2516
2516
internal var _capacity: Int {
2517
+ defer { _fixLifetime(self) }
2517
2518
return _body.capacity
2518
2519
}
2519
2520
2520
2521
@_versioned
2521
2522
internal var _count: Int {
2522
2523
set {
2524
+ defer { _fixLifetime(self) }
2523
2525
_body.count = newValue
2524
2526
}
2525
2527
get {
2528
+ defer { _fixLifetime(self) }
2526
2529
return _body.count
2527
2530
}
2528
2531
}
2529
2532
2530
- internal var _maxLoadFactorInverse : Double {
2533
+ internal var _maxLoadFactorInverse: Double {
2534
+ defer { _fixLifetime(self) }
2531
2535
return _body.maxLoadFactorInverse
2532
2536
}
2533
2537
2538
+ // This API is unsafe and needs a `_fixLifetime` in the caller.
2534
2539
internal
2535
2540
var _initializedHashtableEntriesBitMapStorage: UnsafeMutablePointer<UInt> {
2536
2541
return _roundUp(buffer._elementPointer, toAlignmentOf: UInt.self)
2537
2542
}
2538
2543
2544
+ // This API is unsafe and needs a `_fixLifetime` in the caller.
2539
2545
internal var _keys: UnsafeMutablePointer<Key> {
2540
2546
let bitMapSizeInBytes =
2541
2547
_unsafeMultiply(
2542
- _UnsafeBitMap.sizeInWords(forSizeInBits: _capacity ),
2548
+ _UnsafeBitMap.sizeInWords(forSizeInBits: _body.capacity ),
2543
2549
strideof(UInt.self))
2544
2550
let start =
2545
2551
UnsafeMutablePointer<UInt8>(_initializedHashtableEntriesBitMapStorage)
@@ -2548,8 +2554,9 @@ final internal class _Native${Self}StorageImpl<${TypeParameters}> :
2548
2554
}
2549
2555
2550
2556
%if Self == 'Dictionary':
2557
+ // This API is unsafe and needs a `_fixLifetime` in the caller.
2551
2558
internal var _values: UnsafeMutablePointer<Value> {
2552
- let keysSizeInBytes = _unsafeMultiply(_capacity , strideof(Key.self))
2559
+ let keysSizeInBytes = _unsafeMultiply(_body.capacity , strideof(Key.self))
2553
2560
let start = UnsafeMutablePointer<UInt8>(_keys) + keysSizeInBytes
2554
2561
return _roundUp(start, toAlignmentOf: Value.self)
2555
2562
}
@@ -2660,30 +2667,23 @@ struct _Native${Self}Storage<${TypeParametersDecl}> :
2660
2667
@_transparent
2661
2668
public // @testable
2662
2669
var capacity: Int {
2663
- let result = buffer._capacity
2664
- _fixLifetime(buffer)
2665
- return result
2670
+ return buffer._capacity
2666
2671
}
2667
2672
2668
2673
@_versioned
2669
2674
@_transparent
2670
2675
internal var count: Int {
2671
2676
get {
2672
- let result = buffer._count
2673
- _fixLifetime(buffer)
2674
- return result
2677
+ return buffer._count
2675
2678
}
2676
2679
nonmutating set(newValue) {
2677
2680
buffer._count = newValue
2678
- _fixLifetime(buffer)
2679
2681
}
2680
2682
}
2681
2683
2682
2684
@_transparent
2683
2685
internal var maxLoadFactorInverse: Double {
2684
- let result = buffer._maxLoadFactorInverse
2685
- _fixLifetime(buffer)
2686
- return result
2686
+ return buffer._maxLoadFactorInverse
2687
2687
}
2688
2688
2689
2689
@_versioned
0 commit comments