From c64908621dda57f66b297bc7a45af80dd0002a47 Mon Sep 17 00:00:00 2001 From: Daniel Olsen Date: Mon, 17 May 2021 01:30:34 +0200 Subject: [PATCH] Revert "hash as unsafe bytes" This reverts commit 47610129ff773cc1cbae8edb92365b3b149ddf3e. --- src/azul.rs | 18 +++--------------- src/main.rs | 2 +- 2 files changed, 4 insertions(+), 16 deletions(-) diff --git a/src/azul.rs b/src/azul.rs index c02dca6..c89a527 100644 --- a/src/azul.rs +++ b/src/azul.rs @@ -1,4 +1,4 @@ -use std::{hash::{Hash, Hasher}, ops::{Deref, DerefMut}}; +use std::{hash::Hash, ops::{Deref, DerefMut}}; use rand::prelude::*; use rand::distributions::WeightedIndex; //use smallvec::{SmallVec, smallvec}; @@ -402,8 +402,8 @@ impl Board { } } -#[repr(packed)] -#[derive(Debug, Clone, Copy, PartialEq, Eq)] +//#[repr(align(16))] +#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] pub struct Game { turn: u32, player: u8, @@ -660,18 +660,6 @@ impl Game { } } -unsafe fn any_as_u8_slice(p: &T) -> &[u8] { - ::std::slice::from_raw_parts( - (p as *const T) as *const u8, - ::std::mem::size_of::(), - ) -} -impl Hash for Game { - fn hash(&self, state: &mut H) { - unsafe{any_as_u8_slice(self).deref().hash(state)} - } - -} // Tests diff --git a/src/main.rs b/src/main.rs index 025f162..f03c420 100644 --- a/src/main.rs +++ b/src/main.rs @@ -91,7 +91,7 @@ fn calculate_options() -> Result<(), &'static str> { Ok(()) } -#[cached(size=10_000_000, key = "Game", convert = r#"{ _game }"#)] +#[cached(size=45_000_000, key = "Game", convert = r#"{ _game }"#)] fn count_options(_game: Game, depth: u8, treshold: u8) -> u128 { let before = std::time::Instant::now();