mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-05-03 09:48:32 +00:00
Prefer static const std::regex
std::regex has a relatively expensive constructor, and these are unchanging regexes.
This commit is contained in:
parent
44d93048b3
commit
1df482d51f
3 changed files with 11 additions and 8 deletions
|
@ -102,10 +102,10 @@ std::string Lexer::FetchDelimString(char delim)
|
|||
|
||||
std::string Lexer::FetchWordChars()
|
||||
{
|
||||
// Valid word characters:
|
||||
std::regex rx(R"([a-z\d_])", std::regex_constants::icase);
|
||||
|
||||
return FetchCharsWhile([&rx](char c) { return std::regex_match(std::string(1, c), rx); });
|
||||
return FetchCharsWhile([](char c) {
|
||||
return std::isalpha(c, std::locale::classic()) || std::isdigit(c, std::locale::classic()) ||
|
||||
c == '_';
|
||||
});
|
||||
}
|
||||
|
||||
Token Lexer::GetDelimitedLiteral()
|
||||
|
@ -134,7 +134,8 @@ Token Lexer::GetRealLiteral(char first_char)
|
|||
value += first_char;
|
||||
value += FetchCharsWhile([](char c) { return isdigit(c, std::locale::classic()) || ('.' == c); });
|
||||
|
||||
if (std::regex_match(value, std::regex(R"(\d+(\.\d+)?)")))
|
||||
static const std::regex re(R"(\d+(\.\d+)?)");
|
||||
if (std::regex_match(value, re))
|
||||
return Token(TOK_LITERAL, value);
|
||||
|
||||
return Token(TOK_INVALID);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue