|
11 | 11 | //===----------------------------------------------------------------------===//
|
12 | 12 |
|
13 | 13 | /// A wrapper around a bitmap storage with room for at least `bitCount` bits.
|
14 |
| -@_fixed_layout // FIXME(sil-serialize-all) |
15 |
| -public // @testable |
16 |
| -struct _UnsafeBitMap { |
17 |
| - public // @testable |
18 |
| - let values: UnsafeMutablePointer<UInt> |
| 14 | +@_fixed_layout |
| 15 | +@usableFromInline // @testable |
| 16 | +internal struct _UnsafeBitMap { |
| 17 | + @usableFromInline |
| 18 | + internal let values: UnsafeMutablePointer<UInt> |
19 | 19 |
|
20 |
| - public // @testable |
21 |
| - let bitCount: Int |
| 20 | + @usableFromInline |
| 21 | + internal let bitCount: Int |
22 | 22 |
|
23 |
| - @inlinable // FIXME(sil-serialize-all) |
24 |
| - public // @testable |
25 |
| - static func wordIndex(_ i: Int) -> Int { |
| 23 | + @inlinable |
| 24 | + @inline(__always) |
| 25 | + internal static func wordIndex(_ i: Int) -> Int { |
26 | 26 | // Note: We perform the operation on UInts to get faster unsigned math
|
27 | 27 | // (shifts).
|
28 | 28 | return Int(bitPattern: UInt(bitPattern: i) / UInt(UInt.bitWidth))
|
29 | 29 | }
|
30 | 30 |
|
31 |
| - @inlinable // FIXME(sil-serialize-all) |
32 |
| - public // @testable |
33 |
| - static func bitIndex(_ i: Int) -> UInt { |
| 31 | + @inlinable |
| 32 | + @inline(__always) |
| 33 | + internal static func bitIndex(_ i: Int) -> UInt { |
34 | 34 | // Note: We perform the operation on UInts to get faster unsigned math
|
35 | 35 | // (shifts).
|
36 | 36 | return UInt(bitPattern: i) % UInt(UInt.bitWidth)
|
37 | 37 | }
|
38 | 38 |
|
39 |
| - @inlinable // FIXME(sil-serialize-all) |
40 |
| - public // @testable |
41 |
| - static func sizeInWords(forSizeInBits bitCount: Int) -> Int { |
| 39 | + @inlinable |
| 40 | + @inline(__always) |
| 41 | + internal static func sizeInWords(forSizeInBits bitCount: Int) -> Int { |
42 | 42 | return (bitCount + Int.bitWidth - 1) / Int.bitWidth
|
43 | 43 | }
|
44 | 44 |
|
45 |
| - @inlinable // FIXME(sil-serialize-all) |
46 |
| - public // @testable |
47 |
| - init(storage: UnsafeMutablePointer<UInt>, bitCount: Int) { |
| 45 | + @inlinable |
| 46 | + @inline(__always) |
| 47 | + internal init(storage: UnsafeMutablePointer<UInt>, bitCount: Int) { |
48 | 48 | self.bitCount = bitCount
|
49 | 49 | self.values = storage
|
50 | 50 | }
|
51 | 51 |
|
52 |
| - @inlinable // FIXME(sil-serialize-all) |
53 |
| - public // @testable |
54 |
| - var numberOfWords: Int { |
55 |
| - return _UnsafeBitMap.sizeInWords(forSizeInBits: bitCount) |
| 52 | + @inlinable |
| 53 | + internal var numberOfWords: Int { |
| 54 | + @inline(__always) |
| 55 | + get { |
| 56 | + return _UnsafeBitMap.sizeInWords(forSizeInBits: bitCount) |
| 57 | + } |
56 | 58 | }
|
57 | 59 |
|
58 |
| - @inlinable // FIXME(sil-serialize-all) |
59 |
| - public // @testable |
60 |
| - func initializeToZero() { |
| 60 | + @inlinable |
| 61 | + @inline(__always) |
| 62 | + internal func initializeToZero() { |
61 | 63 | values.initialize(repeating: 0, count: numberOfWords)
|
62 | 64 | }
|
63 | 65 |
|
64 |
| - @inlinable // FIXME(sil-serialize-all) |
65 |
| - public // @testable |
66 |
| - subscript(i: Int) -> Bool { |
| 66 | + @inlinable |
| 67 | + internal subscript(i: Int) -> Bool { |
| 68 | + @inline(__always) |
67 | 69 | get {
|
68 | 70 | _sanityCheck(i < Int(bitCount) && i >= 0, "index out of bounds")
|
69 | 71 | let word = values[_UnsafeBitMap.wordIndex(i)]
|
70 | 72 | let bit = word & (1 << _UnsafeBitMap.bitIndex(i))
|
71 | 73 | return bit != 0
|
72 | 74 | }
|
| 75 | + @inline(__always) |
73 | 76 | nonmutating set {
|
74 | 77 | _sanityCheck(i < Int(bitCount) && i >= 0, "index out of bounds")
|
75 | 78 | let wordIdx = _UnsafeBitMap.wordIndex(i)
|
|
0 commit comments