| ... | @@ -750,12 +750,19 @@ pub fn HashMapUnmanaged( | ... | @@ -750,12 +750,19 @@ pub fn HashMapUnmanaged( |
| 750 | fingerprint: FingerPrint = free, | 750 | fingerprint: FingerPrint = free, |
| 751 | used: u1 = 0, | 751 | used: u1 = 0, |
| 752 | | 752 | |
| | 753 | const slot_free = @bitCast(u8, Metadata{ .fingerprint = free }); |
| | 754 | const slot_tombstone = @bitCast(u8, Metadata{ .fingerprint = tombstone }); |
| | 755 | |
| 753 | pub fn isUsed(self: Metadata) bool { | 756 | pub fn isUsed(self: Metadata) bool { |
| 754 | return self.used == 1; | 757 | return self.used == 1; |
| 755 | } | 758 | } |
| 756 | | 759 | |
| 757 | pub fn isTombstone(self: Metadata) bool { | 760 | pub fn isTombstone(self: Metadata) bool { |
| 758 | return !self.isUsed() and self.fingerprint == tombstone; | 761 | return @bitCast(u8, self) == slot_tombstone; |
| | 762 | } |
| | 763 | |
| | 764 | pub fn isFree(self: Metadata) bool { |
| | 765 | return @bitCast(u8, self) == slot_free; |
| 759 | } | 766 | } |
| 760 | | 767 | |
| 761 | pub fn takeFingerprint(hash: Hash) FingerPrint { | 768 | pub fn takeFingerprint(hash: Hash) FingerPrint { |
| ... | @@ -1115,7 +1122,7 @@ pub fn HashMapUnmanaged( | ... | @@ -1115,7 +1122,7 @@ pub fn HashMapUnmanaged( |
| 1115 | var idx = @truncate(usize, hash & mask); | 1122 | var idx = @truncate(usize, hash & mask); |
| 1116 | | 1123 | |
| 1117 | var metadata = self.metadata.? + idx; | 1124 | var metadata = self.metadata.? + idx; |
| 1118 | while ((metadata[0].isUsed() or metadata[0].isTombstone()) and limit != 0) { | 1125 | while (!metadata[0].isFree() and limit != 0) { |
| 1119 | if (metadata[0].isUsed() and metadata[0].fingerprint == fingerprint) { | 1126 | if (metadata[0].isUsed() and metadata[0].fingerprint == fingerprint) { |
| 1120 | const test_key = &self.keys()[idx]; | 1127 | const test_key = &self.keys()[idx]; |
| 1121 | // If you get a compile error on this line, it means that your generic eql | 1128 | // If you get a compile error on this line, it means that your generic eql |
| ... | @@ -1294,7 +1301,7 @@ pub fn HashMapUnmanaged( | ... | @@ -1294,7 +1301,7 @@ pub fn HashMapUnmanaged( |
| 1294 | | 1301 | |
| 1295 | var first_tombstone_idx: usize = self.capacity(); // invalid index | 1302 | var first_tombstone_idx: usize = self.capacity(); // invalid index |
| 1296 | var metadata = self.metadata.? + idx; | 1303 | var metadata = self.metadata.? + idx; |
| 1297 | while ((metadata[0].isUsed() or metadata[0].isTombstone()) and limit != 0) { | 1304 | while (!metadata[0].isFree() and limit != 0) { |
| 1298 | if (metadata[0].isUsed() and metadata[0].fingerprint == fingerprint) { | 1305 | if (metadata[0].isUsed() and metadata[0].fingerprint == fingerprint) { |
| 1299 | const test_key = &self.keys()[idx]; | 1306 | const test_key = &self.keys()[idx]; |
| 1300 | // If you get a compile error on this line, it means that your generic eql | 1307 | // If you get a compile error on this line, it means that your generic eql |