perf: zobrist table no longer compares hash before overwrites

This commit is contained in:
dogeystamp 2024-11-23 18:51:49 -05:00
parent 8895770da6
commit e79f19942e
No known key found for this signature in database

View File

@ -114,16 +114,15 @@ impl<T: Copy> ZobristTable<T> {
}
impl<T> IndexMut<Zobrist> for ZobristTable<T> {
/// Overwrite a table entry.
///
/// If you `mut`ably index, it will automatically wipe an existing entry,
/// regardless of it was a cache hit or miss.
fn index_mut(&mut self, zobrist: Zobrist) -> &mut Self::Output {
let idx = zobrist.truncate_hash(self.size);
if self.data[idx].0 == zobrist {
&mut self.data[idx].1
} else {
// miss, overwrite
self.data[idx].0 = zobrist;
self.data[idx].1 = None;
&mut self.data[idx].1
}
self.data[idx].0 = zobrist;
self.data[idx].1 = None;
&mut self.data[idx].1
}
}