From e6d0f91832662dada7a36cbf06e112843a5167a1 Mon Sep 17 00:00:00 2001 From: Syrus Date: Tue, 26 Feb 2019 01:12:34 -0800 Subject: [PATCH] Use blake2b SIMD version for increased performance --- lib/runtime-core/src/cache.rs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/runtime-core/src/cache.rs b/lib/runtime-core/src/cache.rs index ec2b0b01f..339b78fcc 100644 --- a/lib/runtime-core/src/cache.rs +++ b/lib/runtime-core/src/cache.rs @@ -2,7 +2,7 @@ use crate::{ module::{Module, ModuleInfo}, sys::Memory, }; -use blake2b_simd::blake2b; +use blake2b_simd::blake2bp; use std::{fmt, io, mem, slice}; #[derive(Debug)] @@ -45,7 +45,10 @@ impl WasmHash { let mut first_part = [0u8; 32]; let mut second_part = [0u8; 32]; - let mut hasher = blake2b(wasm); + let mut state = blake2bp::State::new(); + state.update(wasm); + + let mut hasher = state.finalize(); let generic_array = hasher.as_bytes(); first_part.copy_from_slice(&generic_array[0..32]);