Skip to content

Commit 0b4162b

Browse files
committed
stdlib: make the argument label in _UnsafeBitMap.sizeInWords more clear to avoid bits vs. bytes vs. words confusion
1 parent b811f92 commit 0b4162b

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

stdlib/public/core/HashedCollections.swift.gyb

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2490,7 +2490,7 @@ final internal class _Native${Self}StorageImpl<${TypeParameters}> :
24902490
/// Returns the bytes necessary to store a bit map of 'capacity' bytes and
24912491
/// padding to align the start to word alignment.
24922492
internal static func bytesForBitMap(capacity: Int) -> Int {
2493-
let numWords = _UnsafeBitMap.sizeInWords(forCapacity: capacity)
2493+
let numWords = _UnsafeBitMap.sizeInWords(forSizeInBits: capacity)
24942494
return numWords * strideof(UInt) + alignof(UInt)
24952495
}
24962496

@@ -2554,7 +2554,9 @@ final internal class _Native${Self}StorageImpl<${TypeParameters}> :
25542554

25552555
internal var _keys: UnsafeMutablePointer<Key> {
25562556
let bitMapSizeInBytes =
2557-
_unsafeMultiply(_UnsafeBitMap.sizeInWords(forCapacity: _capacity), strideof(UInt))
2557+
_unsafeMultiply(
2558+
_UnsafeBitMap.sizeInWords(forSizeInBits: _capacity),
2559+
strideof(UInt))
25582560
let start =
25592561
UnsafeMutablePointer<UInt8>(_initializedHashtableEntriesBitMapStorage)
25602562
+ bitMapSizeInBytes

stdlib/public/core/UnsafeBitMap.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ internal struct _UnsafeBitMap {
2727
return UInt(bitPattern: i) % UInt(UInt._sizeInBits)
2828
}
2929

30-
internal static func sizeInWords(forCapacity bitCount: Int) -> Int {
30+
internal static func sizeInWords(forSizeInBits bitCount: Int) -> Int {
3131
return bitCount + Int._sizeInBytes - 1 / Int._sizeInBytes
3232
}
3333

@@ -37,7 +37,7 @@ internal struct _UnsafeBitMap {
3737
}
3838

3939
internal var numberOfWords: Int {
40-
return _UnsafeBitMap.sizeInWords(forCapacity: bitCount)
40+
return _UnsafeBitMap.sizeInWords(forSizeInBits: bitCount)
4141
}
4242

4343
internal func initializeToZero() {

0 commit comments

Comments
 (0)