Skip to content
This repository has been archived by the owner on Apr 7, 2021. It is now read-only.

Commit

Permalink
Function-scope statics aren't as efficient as file-scope ones
Browse files Browse the repository at this point in the history
  • Loading branch information
jackoalan committed Apr 15, 2016
1 parent 4c30986 commit 3a48b3b
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 9 deletions.
6 changes: 2 additions & 4 deletions driver/ToolSpec.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,9 @@ class ToolSpec final : public ToolBase
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;
Expand Down
2 changes: 1 addition & 1 deletion lib/Database/Project.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ namespace Database
{

logvisor::Module LogModule("HECLDatabase");
static const hecl::FourCC HECLfcc("HECL");

/**********************************************
* Project::ConfigFile
Expand Down Expand Up @@ -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);
Expand Down
9 changes: 5 additions & 4 deletions lib/hecl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ namespace hecl
{
unsigned VerbosityLevel = 0;
logvisor::Module LogModule("hecl");
static const std::string Illegals {"<>?*\"|"};

void SanitizePath(std::string& path)
{
Expand All @@ -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 '_';
Expand All @@ -52,6 +52,8 @@ void SanitizePath(std::string& path)
});
}

static const std::wstring WIllegals {L"<>?*\"|"};

void SanitizePath(std::wstring& path)
{
if (path.empty())
Expand All @@ -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'_';
Expand Down

0 comments on commit 3a48b3b

Please sign in to comment.