From fde0f341dd44e0beab853bf14a1523d38f6adaf3 Mon Sep 17 00:00:00 2001 From: fed <58637860+fedddddd@users.noreply.github.com> Date: Thu, 22 Dec 2022 13:21:30 +0100 Subject: [PATCH] Cache file hashes --- src/client/component/party.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/client/component/party.cpp b/src/client/component/party.cpp index ae540440..4f8a3f34 100644 --- a/src/client/component/party.cpp +++ b/src/client/component/party.cpp @@ -175,6 +175,8 @@ namespace party cl_disconnect_hook.invoke(show_main_menu); } + std::unordered_map hash_cache; + std::string get_file_hash(const std::string& file) { if (!utils::io::file_exists(file)) @@ -182,8 +184,15 @@ namespace party return {}; } + const auto iter = hash_cache.find(file); + if (iter != hash_cache.end()) + { + return iter->second; + } + const auto data = utils::io::read_file(file); const auto sha = utils::cryptography::sha1::compute(data, true); + hash_cache[file] = sha; return sha; } @@ -379,6 +388,7 @@ namespace party fastfiles::set_usermap(map); } + hash_cache.clear(); current_sv_mapname = map; utils::hook::invoke(0x54BBB0_b, map, a2, a3, a4, a5); }