mirror of
https://github.com/apple/swift-collections
synced 2026-11-26 04:47:48 +00:00
[BasicContainers] Fix incorrect wraparound implementation in hashed container insertions with NO_ROBIN_HOOD_HASHING
This commit is contained in:
2 files changed
+7
-2
No files matched your search
@@ -86,8 +86,10 @@ extension _HTable.Bitmap {
|
||||
}
|
||||
}
|
||||
|
||||
/// Note: If the bitmap has fewer than Word.capacity bits, then this may
|
||||
/// report an unoccupied bit beyond the end of its actual size.
|
||||
@inlinable
|
||||
package func firstUnoccupiedBucket(wrappingFrom start: Bucket) -> Bucket {
|
||||
package func firstUnoccupiedBucket(from start: Bucket) -> Bucket {
|
||||
assert(isValid(start))
|
||||
var word = start.word
|
||||
var bits = _words[word]
|
||||
|
||||
@@ -36,7 +36,10 @@ extension _HTable {
|
||||
#if COLLECTIONS_NO_ROBIN_HOOD_HASHING
|
||||
let ideal = idealBucket(forHashValue: hashValue)
|
||||
let bitmap = self.bitmap
|
||||
let actual = bitmap.nextUnoccupiedBucket(wrappingFrom: ideal)
|
||||
var actual = bitmap.firstUnoccupiedBucket(from: ideal)
|
||||
if actual._offset >= self.bucketCount {
|
||||
actual = bitmap.firstUnoccupiedBucket(from: Bucket(offset: 0))
|
||||
}
|
||||
bitmap.setOccupied(actual)
|
||||
let probeLength = self.probeLength(from: ideal, to: actual)
|
||||
_maxProbeLength = Swift.max(_maxProbeLength, probeLength)
|
||||
|
||||
Reference in new issue
Block a user