From 56da0576a6dff2587912e2872656a28bc84aca98 Mon Sep 17 00:00:00 2001 From: Kawe Mazidjatari <48657826+Mauler125@users.noreply.github.com> Date: Mon, 3 Jul 2023 02:27:09 +0200 Subject: [PATCH] Make static to source file Should be made static to avoid unwanted bloat in compiled output, as each translation unit will create a new initializer/destructor. -10KiB compiled code for GameSDK. --- r5dev/core/logger.cpp | 1 + r5dev/public/tier0/dbg.h | 1 - r5dev/vpklib/packedstore.cpp | 9 ++++++--- r5dev/vpklib/packedstore.h | 3 --- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/r5dev/core/logger.cpp b/r5dev/core/logger.cpp index 4c5e897a..67e665d4 100644 --- a/r5dev/core/logger.cpp +++ b/r5dev/core/logger.cpp @@ -12,6 +12,7 @@ #ifndef NETCONSOLE #include "vscript/languages/squirrel_re/include/sqstdaux.h" #endif // !NETCONSOLE +static const std::regex s_AnsiRowRegex("\\\033\\[.*?m"); std::mutex g_LogMutex; #if !defined (DEDICATED) && !defined (NETCONSOLE) diff --git a/r5dev/public/tier0/dbg.h b/r5dev/public/tier0/dbg.h index 22619bfb..bc60a332 100644 --- a/r5dev/public/tier0/dbg.h +++ b/r5dev/public/tier0/dbg.h @@ -96,7 +96,6 @@ constexpr const char* s_ScriptAnsiColor[4] = "\033[38;2;151;149;163mScript(X):" }; -static const std::regex s_AnsiRowRegex("\\\033\\[.*?m"); extern std::mutex g_LogMutex; ////////////////////////////////////////////////////////////////////////// diff --git a/r5dev/vpklib/packedstore.cpp b/r5dev/vpklib/packedstore.cpp index deda0045..64a2d21e 100644 --- a/r5dev/vpklib/packedstore.cpp +++ b/r5dev/vpklib/packedstore.cpp @@ -34,6 +34,9 @@ #include "vpc/keyvalues.h" #include "vpklib/packedstore.h" +static const std::regex s_DirFileRegex{ R"((?:.*\/)?([^_]*_)(.*)(.bsp.pak000_dir).*)" }; +static const std::regex s_BlockFileRegex{ R"(pak000_([0-9]{3}))" }; + //----------------------------------------------------------------------------- // Purpose: initialize parameters for compression algorithm //----------------------------------------------------------------------------- @@ -168,7 +171,7 @@ bool CPackedStore::GetEntryValues(CUtlVector& entryValues, CUtlString CPackedStore::GetNameParts(const CUtlString& dirFileName, int nCaptureGroup) const { std::cmatch regexMatches; - std::regex_search(dirFileName.Get(), regexMatches, DIR_REGEX); + std::regex_search(dirFileName.Get(), regexMatches, s_DirFileRegex); return regexMatches[nCaptureGroup].str().c_str(); } @@ -181,7 +184,7 @@ CUtlString CPackedStore::GetNameParts(const CUtlString& dirFileName, int nCaptur CUtlString CPackedStore::GetLevelName(const CUtlString& dirFileName) const { std::cmatch regexMatches; - std::regex_search(dirFileName.Get(), regexMatches, DIR_REGEX); + std::regex_search(dirFileName.Get(), regexMatches, s_DirFileRegex); CUtlString result; result.Format("%s%s", regexMatches[1].str().c_str(), regexMatches[2].str().c_str()); @@ -826,7 +829,7 @@ VPKDir_t::VPKDir_t(const CUtlString& dirFilePath, bool bSanitizeName) } std::cmatch regexMatches; - std::regex_search(dirFilePath.String(), regexMatches, BLOCK_REGEX); + std::regex_search(dirFilePath.String(), regexMatches, s_BlockFileRegex); if (regexMatches.empty()) { diff --git a/r5dev/vpklib/packedstore.h b/r5dev/vpklib/packedstore.h index d5539aa6..29b66db6 100644 --- a/r5dev/vpklib/packedstore.h +++ b/r5dev/vpklib/packedstore.h @@ -24,9 +24,6 @@ constexpr int PACKFILEINDEX_SEP = 0x0; constexpr int PACKFILEINDEX_END = 0xffff; constexpr const char VPK_IGNORE_FILE[] = ".vpkignore"; -static const std::regex BLOCK_REGEX{ R"(pak000_([0-9]{3}))" }; -static const std::regex DIR_REGEX{ R"((?:.*\/)?([^_]*_)(.*)(.bsp.pak000_dir).*)" }; - static const char* const DIR_TARGET[] { "server",