From e662699b992108c50602944647cded05df6beba9 Mon Sep 17 00:00:00 2001 From: Observer KRypt0n_ Date: Sun, 26 Feb 2023 13:59:28 +0200 Subject: [PATCH] perf: changed md5 library to use asm instructions --- Cargo.toml | 4 ++-- anime-game-core | 2 +- src/fps_unlocker/mod.rs | 4 +++- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 9c25113..5ecfe67 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -19,14 +19,14 @@ enum-ordinalize = { version = "3.1", optional = true } wincompatlib = { version = "0.2", optional = true } lazy_static = { version = "1.4", optional = true } -md5 = { version = "0.7", optional = true } +md-5 = { version = "0.10", features = ["asm"], optional = true } [features] states = [] config = ["dep:serde", "dep:serde_json", "dep:enum-ordinalize"] components = ["dep:wincompatlib", "dep:lazy_static"] game = ["components", "config"] -fps-unlocker = ["dep:md5"] +fps-unlocker = ["dep:md-5"] default = ["all"] all = ["states", "config", "components", "game", "fps-unlocker"] diff --git a/anime-game-core b/anime-game-core index 96cee06..ef498b2 160000 --- a/anime-game-core +++ b/anime-game-core @@ -1 +1 @@ -Subproject commit 96cee069953819eb0ee758298c05b5eb2b8f6b7f +Subproject commit ef498b2e16f9b4cc4c1ee6357e73caf4fbc81dec diff --git a/src/fps_unlocker/mod.rs b/src/fps_unlocker/mod.rs index c2f5b6f..8e038c2 100644 --- a/src/fps_unlocker/mod.rs +++ b/src/fps_unlocker/mod.rs @@ -2,6 +2,8 @@ use std::path::PathBuf; use anime_game_core::installer::downloader::Downloader; +use md5::{Md5, Digest}; + use crate::config::game::enhancements::fps_unlocker::config::Config as FpsUnlockerConfig; pub mod config_schema; @@ -26,7 +28,7 @@ impl FpsUnlocker { pub fn from_dir + std::fmt::Debug>(dir: T) -> anyhow::Result> { let dir = dir.into(); - let hash = format!("{:x}", md5::compute(std::fs::read(dir.join("unlocker.exe"))?)); + let hash = format!("{:x}", Md5::digest(std::fs::read(dir.join("unlocker.exe"))?)); Ok(if hash == LATEST_INFO.0 { Some(Self { dir })