Skip to content

Commit

Permalink
refactor(database): replace SipHasher with DefaultHasher
Browse files Browse the repository at this point in the history
  • Loading branch information
ShenMian committed Jun 19, 2024
1 parent 46bde77 commit 51c7bb7
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 15 deletions.
7 changes: 0 additions & 7 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ soukoban = { git = "https://github.com/ShenMian/soukoban" }
bitflags = "2.4"
nalgebra = "0.32"
itertools = "0.13"
siphasher = "1.0"

leafwing-input-manager = "0.13"
bevy_kira_audio = "0.19"
Expand Down
5 changes: 2 additions & 3 deletions src/database.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
use std::hash::{Hash, Hasher};
use std::hash::{DefaultHasher, Hash, Hasher};
use std::path::Path;
use std::str::FromStr;

use rusqlite::Connection;
use siphasher::sip::SipHasher24;
use soukoban::{Actions, Level};

pub struct Database {
Expand Down Expand Up @@ -223,7 +222,7 @@ impl Database {

/// Computes a normalized hash for the provided level.
fn normalized_hash(level: &Level) -> String {
let mut hasher = SipHasher24::new();
let mut hasher = DefaultHasher::new();
let mut normalized_level = level.clone();
normalized_level.normalize();
normalized_level.hash(&mut hasher);
Expand Down
3 changes: 2 additions & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ fn load_input_map() -> InputMap<Action> {
fs::write(KEYMAP_FILE_PATH, default_keymap_toml).unwrap();
}
let keymap_toml = fs::read_to_string(KEYMAP_FILE_PATH).unwrap();
let input_map: InputMap<Action> = toml::from_str(keymap_toml.as_str()).unwrap();
let input_map: InputMap<Action> =
toml::from_str(keymap_toml.as_str()).expect("failed to parse `keymap.toml`");
input_map
}

Expand Down
5 changes: 2 additions & 3 deletions src/solve/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,12 @@ use std::{
cell::OnceCell,
cmp::Ordering,
collections::HashSet,
hash::{Hash, Hasher},
hash::{DefaultHasher, Hash, Hasher},
};

use crate::solve::solver::*;

use nalgebra::Vector2;
use siphasher::sip::SipHasher24;
use soukoban::{
deadlock,
direction::Direction,
Expand Down Expand Up @@ -184,7 +183,7 @@ impl State {

/// Returns a normalized hash of the current state.
pub fn normalized_hash(&self, solver: &Solver) -> u64 {
let mut hasher = SipHasher24::new();
let mut hasher = DefaultHasher::new();
self.normalized(solver).hash(&mut hasher);
hasher.finish()
}
Expand Down

0 comments on commit 51c7bb7

Please sign in to comment.