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.
This commit is contained in:
Kawe Mazidjatari 2023-07-03 02:27:09 +02:00
parent f6f3c7f9a2
commit 56da0576a6
4 changed files with 7 additions and 7 deletions

View File

@ -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)

View File

@ -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;
//////////////////////////////////////////////////////////////////////////

View File

@ -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<VPKKeyValues_t>& 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())
{

View File

@ -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",