Skip to content

Commit b811f92

Browse files
committed
stdlib: rename _BitMap to _UnsafeBitMap
_BitMap is nothing more than a convenience wrapper around an UnsafeMutablePointer.
1 parent 389fa5f commit b811f92

File tree

2 files changed

+14
-14
lines changed

2 files changed

+14
-14
lines changed

stdlib/public/core/HashedCollections.swift.gyb

Lines changed: 8 additions & 8 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 = _BitMap.sizeInWords(forCapacity: capacity)
2493+
let numWords = _UnsafeBitMap.sizeInWords(forCapacity: capacity)
24942494
return numWords * strideof(UInt) + alignof(UInt)
24952495
}
24962496

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

25552555
internal var _keys: UnsafeMutablePointer<Key> {
25562556
let bitMapSizeInBytes =
2557-
_unsafeMultiply(_BitMap.sizeInWords(forCapacity: _capacity), strideof(UInt))
2557+
_unsafeMultiply(_UnsafeBitMap.sizeInWords(forCapacity: _capacity), strideof(UInt))
25582558
let start =
25592559
UnsafeMutablePointer<UInt8>(_initializedHashtableEntriesBitMapStorage)
25602560
+ bitMapSizeInBytes
@@ -2582,7 +2582,7 @@ final internal class _Native${Self}StorageImpl<${TypeParameters}> :
25822582
return _HashedContainerStorageHeader(capacity: capacity)
25832583
}
25842584
let storage = r as! StorageImpl
2585-
let initializedEntries = _BitMap(
2585+
let initializedEntries = _UnsafeBitMap(
25862586
storage: storage._initializedHashtableEntriesBitMapStorage,
25872587
bitCount: capacity)
25882588
initializedEntries.initializeToZero()
@@ -2591,7 +2591,7 @@ final internal class _Native${Self}StorageImpl<${TypeParameters}> :
25912591

25922592
deinit {
25932593
let capacity = _capacity
2594-
let initializedEntries = _BitMap(
2594+
let initializedEntries = _UnsafeBitMap(
25952595
storage: _initializedHashtableEntriesBitMapStorage, bitCount: capacity)
25962596
let keys = _keys
25972597
%if Self == 'Dictionary':
@@ -2641,15 +2641,15 @@ struct _Native${Self}Storage<${TypeParametersDecl}> :
26412641

26422642
internal let buffer: StorageImpl
26432643

2644-
internal let initializedEntries: _BitMap
2644+
internal let initializedEntries: _UnsafeBitMap
26452645
internal let keys: UnsafeMutablePointer<Key>
26462646
%if Self == 'Dictionary':
26472647
internal let values: UnsafeMutablePointer<Value>
26482648
%end
26492649

26502650
internal init(capacity: Int) {
26512651
buffer = StorageImpl.create(capacity: capacity)
2652-
initializedEntries = _BitMap(
2652+
initializedEntries = _UnsafeBitMap(
26532653
storage: buffer._initializedHashtableEntriesBitMapStorage,
26542654
bitCount: capacity)
26552655
keys = buffer._keys
@@ -3055,15 +3055,15 @@ internal struct _BridgedNative${Self}Storage {
30553055
internal typealias SequenceElement = ${AnySequenceType}
30563056

30573057
internal let buffer: StorageImpl
3058-
internal let initializedEntries: _BitMap
3058+
internal let initializedEntries: _UnsafeBitMap
30593059
internal let keys: UnsafeMutablePointer<AnyObject>
30603060
%if Self == 'Dictionary':
30613061
internal let values: UnsafeMutablePointer<AnyObject>
30623062
%end
30633063

30643064
internal init(buffer: StorageImpl) {
30653065
self.buffer = buffer
3066-
initializedEntries = _BitMap(
3066+
initializedEntries = _UnsafeBitMap(
30673067
storage: buffer._initializedHashtableEntriesBitMapStorage,
30683068
bitCount: buffer._capacity)
30693069
keys = buffer._keys

stdlib/public/core/UnsafeBitMap.swift

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
//===----------------------------------------------------------------------===//
1212

1313
/// A wrapper around a bitmap storage with room for at least `bitCount` bits.
14-
internal struct _BitMap {
14+
internal struct _UnsafeBitMap {
1515
internal let values: UnsafeMutablePointer<UInt>
1616
internal let bitCount: Int
1717

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

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

4343
internal func initializeToZero() {
@@ -47,14 +47,14 @@ internal struct _BitMap {
4747
internal subscript(i: Int) -> Bool {
4848
get {
4949
_sanityCheck(i < Int(bitCount) && i >= 0, "index out of bounds")
50-
let word = values[_BitMap.wordIndex(i)]
51-
let bit = word & (1 << _BitMap.bitIndex(i))
50+
let word = values[_UnsafeBitMap.wordIndex(i)]
51+
let bit = word & (1 << _UnsafeBitMap.bitIndex(i))
5252
return bit != 0
5353
}
5454
nonmutating set {
5555
_sanityCheck(i < Int(bitCount) && i >= 0, "index out of bounds")
56-
let wordIdx = _BitMap.wordIndex(i)
57-
let bitMask = 1 << _BitMap.bitIndex(i)
56+
let wordIdx = _UnsafeBitMap.wordIndex(i)
57+
let bitMask = 1 << _UnsafeBitMap.bitIndex(i)
5858
if newValue {
5959
values[wordIdx] = values[wordIdx] | bitMask
6060
} else {

0 commit comments

Comments
 (0)