From bc995230fae0c86190a3b21c6ffacbd567eb30f1 Mon Sep 17 00:00:00 2001 From: Kawe Mazidjatari <48657826+Mauler125@users.noreply.github.com> Date: Mon, 19 Jun 2023 22:36:46 +0200 Subject: [PATCH] Avoid extraneous string copy Take raw pointer directly, this is currently the only way these functions get called with. --- r5dev/public/tier0/sigcache.h | 4 ++-- r5dev/tier0/sigcache.cpp | 10 +++++----- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/r5dev/public/tier0/sigcache.h b/r5dev/public/tier0/sigcache.h index 47a338ca..989a8db9 100644 --- a/r5dev/public/tier0/sigcache.h +++ b/r5dev/public/tier0/sigcache.h @@ -29,8 +29,8 @@ public: void AddEntry(const char* szPattern, const uint64_t nRVA); bool FindEntry(const char* szPattern, uint64_t& nRVA); - bool LoadCache(const string& svCacheFile); - bool WriteCache(const string& svCacheFile) const; + bool LoadCache(const char* szCacheFile); + bool WriteCache(const char* szCacheFile) const; private: bool CompressBlob(const size_t nSrcLen, size_t& nDstLen, uint32_t& nAdler32, const uint8_t* pSrcBuf, uint8_t* pDstBuf) const; diff --git a/r5dev/tier0/sigcache.cpp b/r5dev/tier0/sigcache.cpp index 56cc56c1..51dcda43 100644 --- a/r5dev/tier0/sigcache.cpp +++ b/r5dev/tier0/sigcache.cpp @@ -83,7 +83,7 @@ bool CSigCache::FindEntry(const char* szPattern, uint64_t& nRVA) // Purpose: loads the cache map from the disk // Output : true on success, false otherwise //----------------------------------------------------------------------------- -bool CSigCache::LoadCache(const string& svCacheFile) +bool CSigCache::LoadCache(const char* szCacheFile) { Assert(!m_bInitialized); // Recursive load. @@ -93,7 +93,7 @@ bool CSigCache::LoadCache(const string& svCacheFile) } CIOStream reader; - if (!reader.Open(svCacheFile, CIOStream::READ | CIOStream::BINARY)) + if (!reader.Open(szCacheFile, CIOStream::READ | CIOStream::BINARY)) { return false; } @@ -159,7 +159,7 @@ bool CSigCache::LoadCache(const string& svCacheFile) // Purpose: writes the cache map to the disk // Output : true on success, false otherwise //----------------------------------------------------------------------------- -bool CSigCache::WriteCache(const string& svCacheFile) const +bool CSigCache::WriteCache(const char* szCacheFile) const { if (m_bDisabled || m_bInitialized) { @@ -168,10 +168,10 @@ bool CSigCache::WriteCache(const string& svCacheFile) const } CIOStream writer; - if (!writer.Open(svCacheFile, CIOStream::WRITE | CIOStream::BINARY)) + if (!writer.Open(szCacheFile, CIOStream::WRITE | CIOStream::BINARY)) { Error(eDLL_T::COMMON, NO_ERROR, "%s - Unable to write to '%s' (read-only?)\n", - __FUNCTION__, svCacheFile.c_str()); + __FUNCTION__, szCacheFile); return false; }