Function-scope statics aren't as efficient as file-scope ones

This commit is contained in:
Jack Andersen 2016-04-14 17:24:51 -10:00
parent 1404f84480
commit 037404c5ff
3 changed files with 8 additions and 9 deletions

View File

@ -28,11 +28,9 @@ public:
hecl::SystemString firstArg = info.args.front();
hecl::ToLower(firstArg);
static const hecl::SystemString enable(_S("enable"));
static const hecl::SystemString disable(_S("disable"));
if (!firstArg.compare(enable))
if (!firstArg.compare(_S("enable")))
mode = MENABLE;
else if (!firstArg.compare(disable))
else if (!firstArg.compare(_S("disable")))
mode = MDISABLE;
else
return;

View File

@ -18,6 +18,7 @@ namespace Database
{
logvisor::Module LogModule("HECLDatabase");
static const hecl::FourCC HECLfcc("HECL");
/**********************************************
* Project::ConfigFile
@ -231,7 +232,6 @@ Project::Project(const ProjectRootPath& rootPath)
uint32_t version;
} beacon;
#define DATA_VERSION 1
static const hecl::FourCC HECLfcc("HECL");
if (fread(&beacon, 1, sizeof(beacon), bf) != sizeof(beacon))
{
fseek(bf, 0, SEEK_SET);

View File

@ -20,6 +20,7 @@ namespace hecl
{
unsigned VerbosityLevel = 0;
logvisor::Module LogModule("hecl");
static const std::string Illegals {"<>?*\"|"};
void SanitizePath(std::string& path)
{
@ -31,8 +32,7 @@ void SanitizePath(std::string& path)
bool ic = false;
std::transform(path.begin(), path.end(), path.begin(), [&](const char a) -> char {
++p1;
static const std::string illegals {"<>?*\"|"};
if (illegals.find_first_of(a) != std::string::npos)
if (Illegals.find_first_of(a) != std::string::npos)
{
ic = false;
return '_';
@ -52,6 +52,8 @@ void SanitizePath(std::string& path)
});
}
static const std::wstring WIllegals {L"<>?*\"|"};
void SanitizePath(std::wstring& path)
{
if (path.empty())
@ -62,8 +64,7 @@ void SanitizePath(std::wstring& path)
bool ic = false;
std::transform(path.begin(), path.end(), path.begin(), [&](const wchar_t a) -> wchar_t {
++p1;
static const std::wstring illegals {L"<>?*\"|"};
if (illegals.find_first_of(a) != std::wstring::npos)
if (WIllegals.find_first_of(a) != std::wstring::npos)
{
ic = false;
return L'_';