Change SipHash2-4 -> SipHash1-3 (#780)
This seems to significantly improves performance. Inspired by https://github.com/rust-lang/rust/pull/107925
This commit is contained in:
parent
f8966f9e86
commit
d0afba959d
@ -17,7 +17,7 @@ use memmap2::Mmap;
|
||||
use notify::{RecommendedWatcher, RecursiveMode, Watcher};
|
||||
use once_cell::unsync::OnceCell;
|
||||
use same_file::{is_same_file, Handle};
|
||||
use siphasher::sip128::{Hasher128, SipHasher};
|
||||
use siphasher::sip128::{Hasher128, SipHasher13};
|
||||
use termcolor::{ColorChoice, StandardStream, WriteColor};
|
||||
use typst::diag::{FileError, FileResult, SourceError, StrResult};
|
||||
use typst::eval::Library;
|
||||
@ -535,7 +535,7 @@ impl PathHash {
|
||||
fn new(path: &Path) -> FileResult<Self> {
|
||||
let f = |e| FileError::from_io(e, path);
|
||||
let handle = Handle::from_path(path).map_err(f)?;
|
||||
let mut state = SipHasher::new();
|
||||
let mut state = SipHasher13::new();
|
||||
handle.hash(&mut state);
|
||||
Ok(Self(state.finish128().as_u128()))
|
||||
}
|
||||
|
@ -5,7 +5,7 @@ use std::hash::{Hash, Hasher};
|
||||
use std::sync::Arc;
|
||||
|
||||
use ecow::eco_format;
|
||||
use siphasher::sip128::{Hasher128, SipHasher};
|
||||
use siphasher::sip128::{Hasher128, SipHasher13};
|
||||
|
||||
use super::{
|
||||
cast_to_value, format_str, ops, Args, Array, Cast, CastInfo, Content, Dict, Func,
|
||||
@ -313,7 +313,7 @@ where
|
||||
fn hash128(&self) -> u128 {
|
||||
// Also hash the TypeId since values with different types but
|
||||
// equal data should be different.
|
||||
let mut state = SipHasher::new();
|
||||
let mut state = SipHasher13::new();
|
||||
self.type_id().hash(&mut state);
|
||||
self.hash(&mut state);
|
||||
state.finish128().as_u128()
|
||||
|
@ -12,7 +12,7 @@ use std::num::NonZeroUsize;
|
||||
use std::path::{Component, Path, PathBuf};
|
||||
use std::sync::Arc;
|
||||
|
||||
use siphasher::sip128::{Hasher128, SipHasher};
|
||||
use siphasher::sip128::{Hasher128, SipHasher13};
|
||||
|
||||
/// Turn a closure into a struct implementing [`Debug`].
|
||||
pub fn debug<F>(f: F) -> impl Debug
|
||||
@ -35,7 +35,7 @@ where
|
||||
|
||||
/// Calculate a 128-bit siphash of a value.
|
||||
pub fn hash128<T: Hash + ?Sized>(value: &T) -> u128 {
|
||||
let mut state = SipHasher::new();
|
||||
let mut state = SipHasher13::new();
|
||||
value.hash(&mut state);
|
||||
state.finish128().as_u128()
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user