diff --git a/library/src/include/option_util.h b/library/src/include/option_util.h index a23c262b..cf2614f8 100644 --- a/library/src/include/option_util.h +++ b/library/src/include/option_util.h @@ -35,10 +35,8 @@ #include // Regular expression for token delimiters (whitespace and commas) -static const std::regex program_options_regex{"[, \\f\\n\\r\\t\\v]+", - std::regex_constants::optimize}; - -static const std::regex vector_delim{",", std::regex_constants::optimize}; +#define PROGRAM_OPTIONS_REGEX "[, \\f\\n\\r\\t\\v]+" +#define VECTOR_DELIM "," // variables_map is a set of seen options using variables_map = std::set; @@ -264,6 +262,9 @@ class options_description // Parse an option at the current (argc, argv) position void parse_option(int& argc, char**& argv, variables_map& vm, bool ignoreUnknown = false) const { + static const std::regex program_options_regex{PROGRAM_OPTIONS_REGEX, + std::regex_constants::optimize}; + // Iterate across all options for(const auto& opt : m_optlist) { @@ -312,6 +313,9 @@ class options_description // Formatted output of command-line arguments description friend std::ostream& operator<<(std::ostream& os, const options_description& d) { + static const std::regex program_options_regex{PROGRAM_OPTIONS_REGEX, + std::regex_constants::optimize}; + // Iterate across all options for(const auto& opt : d.m_optlist) { @@ -404,6 +408,8 @@ inline void notify(const variables_map&) {} void parse_arg_ints(std::string const& inStr, std::vector& outVector) { + static const std::regex vector_delim{VECTOR_DELIM, std::regex_constants::optimize}; + // std::cout << inStr << std::endl; for(std::sregex_token_iterator tok{inStr.begin(), inStr.end(), vector_delim, -1}; tok != std::sregex_token_iterator(); @@ -415,6 +421,8 @@ void parse_arg_ints(std::string const& inStr, std::vector& outVector) void parse_arg_strings(std::string const& inStr, std::vector& outVector) { + static const std::regex vector_delim{VECTOR_DELIM, std::regex_constants::optimize}; + // std::cout << inStr << std::endl; for(std::sregex_token_iterator tok{inStr.begin(), inStr.end(), vector_delim, -1}; tok != std::sregex_token_iterator(); diff --git a/library/src/solution_map.cpp b/library/src/solution_map.cpp index 2081ddca..9ad64e1a 100644 --- a/library/src/solution_map.cpp +++ b/library/src/solution_map.cpp @@ -31,7 +31,7 @@ namespace fs = std::filesystem; -static std::regex regEx("[^:;,\"\\{\\}\\[\\s]+", std::regex_constants::optimize); +#define REGEX "[^:;,\"\\{\\}\\[\\s]+" static const char* def_solution_map_path = "rocfft_solution_map.dat"; @@ -477,6 +477,8 @@ size_t solution_map::add_solution(const ProblemKey& probKey, // parse the format version of the input file, call by converter bool solution_map::get_solution_map_version(const fs::path& sol_map_in_path) { + static std::regex regEx(REGEX, std::regex_constants::optimize); + if(LOG_TRACE_ENABLED()) (*LogSingleton::GetInstance().GetTraceOS()) << "reading solution map data from: " << sol_map_in_path.c_str() << std::endl; @@ -505,6 +507,8 @@ bool solution_map::get_solution_map_version(const fs::path& sol_map_in_path) // read the map from input stream bool solution_map::read_solution_map_data(const fs::path& sol_map_in_path, bool primary_map) { + static std::regex regEx(REGEX, std::regex_constants::optimize); + if(LOG_TRACE_ENABLED()) (*LogSingleton::GetInstance().GetTraceOS()) << "reading solution map data from: " << sol_map_in_path.c_str() << std::endl;