diff options
| author | AloXado320 <david.albujar.s.30@gmail.com> | 2026-01-24 00:46:11 -0500 |
|---|---|---|
| committer | Lywx <kiritodev01@gmail.com> | 2026-01-24 00:15:07 -0600 |
| commit | 9d468174cc752e31d06463a7fe7100a39ec86af7 (patch) | |
| tree | 2a1d6a39d4a95b7a8e89dd71be95084dd217c2c5 /src/utils | |
| parent | 963a1f6830f1080a33f581c8b935c49060899214 (diff) | |
Build using C++17 and replace sha1 library
Diffstat (limited to 'src/utils')
| -rw-r--r-- | src/utils/Decompressor.cpp | 5 | ||||
| -rw-r--r-- | src/utils/TorchUtils.h | 9 |
2 files changed, 12 insertions, 2 deletions
diff --git a/src/utils/Decompressor.cpp b/src/utils/Decompressor.cpp index 934a84f..9181099 100644 --- a/src/utils/Decompressor.cpp +++ b/src/utils/Decompressor.cpp @@ -1,4 +1,5 @@ #include "Decompressor.h" +#include "TorchUtils.h" #include <stdexcept> #include "spdlog/spdlog.h" @@ -15,7 +16,7 @@ std::unordered_map<uint32_t, DataChunk*> gCachedChunks; DataChunk* Decompressor::Decode(const std::vector<uint8_t>& buffer, const uint32_t offset, const CompressionType type, bool ignoreCache) { - if(!ignoreCache && gCachedChunks.contains(offset)){ + if(!ignoreCache && Torch::contains(gCachedChunks, offset)){ return gCachedChunks[offset]; } @@ -61,7 +62,7 @@ DataChunk* Decompressor::Decode(const std::vector<uint8_t>& buffer, const uint32 } DataChunk* Decompressor::DecodeTKMK00(const std::vector<uint8_t>& buffer, const uint32_t offset, const uint32_t size, const uint32_t alpha) { - if(gCachedChunks.contains(offset)){ + if(Torch::contains(gCachedChunks, offset)){ return gCachedChunks[offset]; } diff --git a/src/utils/TorchUtils.h b/src/utils/TorchUtils.h index 8b7a3f1..275ec47 100644 --- a/src/utils/TorchUtils.h +++ b/src/utils/TorchUtils.h @@ -24,6 +24,15 @@ std::string to_hex(T number, const bool append0x = true) { return format; } +template <typename Container, typename Key> +constexpr bool contains(const Container& c, const Key& k) { +#if __cplusplus >= 202002L + return c.contains(k); +#else + return c.find(k) != c.end(); +#endif +} + uint32_t translate(uint32_t offset); std::vector<std::filesystem::directory_entry> getRecursiveEntries(const std::filesystem::path baseDir); |
