mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-01-10 08:09:26 +01: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
@ -443,7 +443,7 @@ std::string PPCDebugInterface::GetDescription(u32 address) const
|
|||||||
std::optional<u32>
|
std::optional<u32>
|
||||||
PPCDebugInterface::GetMemoryAddressFromInstruction(const std::string& instruction) const
|
PPCDebugInterface::GetMemoryAddressFromInstruction(const std::string& instruction) const
|
||||||
{
|
{
|
||||||
std::regex re(",[^r0-]*(-?)(0[xX]?[0-9a-fA-F]*|r\\d+)[^r^s]*.(p|toc|\\d+)");
|
static const std::regex re(",[^r0-]*(-?)(0[xX]?[0-9a-fA-F]*|r\\d+)[^r^s]*.(p|toc|\\d+)");
|
||||||
std::smatch match;
|
std::smatch match;
|
||||||
|
|
||||||
// Instructions should be identified as a load or store before using this function. This error
|
// Instructions should be identified as a load or store before using this function. This error
|
||||||
|
@ -100,7 +100,9 @@ void BroadbandAdapterSettingsDialog::SaveAddress()
|
|||||||
switch (m_bba_type)
|
switch (m_bba_type)
|
||||||
{
|
{
|
||||||
case Type::Ethernet:
|
case Type::Ethernet:
|
||||||
if (!std::regex_match(bba_new_address, std::regex("([0-9A-Fa-f]{2}:){5}([0-9A-Fa-f]{2})")))
|
{
|
||||||
|
static const std::regex re_mac_address("([0-9A-Fa-f]{2}:){5}([0-9A-Fa-f]{2})");
|
||||||
|
if (!std::regex_match(bba_new_address, re_mac_address))
|
||||||
{
|
{
|
||||||
ModalMessageBox::critical(
|
ModalMessageBox::critical(
|
||||||
this, tr("Broadband Adapter Error"),
|
this, tr("Broadband Adapter Error"),
|
||||||
@ -111,7 +113,7 @@ void BroadbandAdapterSettingsDialog::SaveAddress()
|
|||||||
}
|
}
|
||||||
Config::SetBaseOrCurrent(Config::MAIN_BBA_MAC, bba_new_address);
|
Config::SetBaseOrCurrent(Config::MAIN_BBA_MAC, bba_new_address);
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
case Type::BuiltIn:
|
case Type::BuiltIn:
|
||||||
Config::SetBaseOrCurrent(Config::MAIN_BBA_BUILTIN_DNS, bba_new_address);
|
Config::SetBaseOrCurrent(Config::MAIN_BBA_BUILTIN_DNS, bba_new_address);
|
||||||
break;
|
break;
|
||||||
|
@ -102,10 +102,10 @@ std::string Lexer::FetchDelimString(char delim)
|
|||||||
|
|
||||||
std::string Lexer::FetchWordChars()
|
std::string Lexer::FetchWordChars()
|
||||||
{
|
{
|
||||||
// Valid word characters:
|
return FetchCharsWhile([](char c) {
|
||||||
std::regex rx(R"([a-z\d_])", std::regex_constants::icase);
|
return std::isalpha(c, std::locale::classic()) || std::isdigit(c, std::locale::classic()) ||
|
||||||
|
c == '_';
|
||||||
return FetchCharsWhile([&rx](char c) { return std::regex_match(std::string(1, c), rx); });
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
Token Lexer::GetDelimitedLiteral()
|
Token Lexer::GetDelimitedLiteral()
|
||||||
@ -134,7 +134,8 @@ Token Lexer::GetRealLiteral(char first_char)
|
|||||||
value += first_char;
|
value += first_char;
|
||||||
value += FetchCharsWhile([](char c) { return isdigit(c, std::locale::classic()) || ('.' == c); });
|
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_LITERAL, value);
|
||||||
|
|
||||||
return Token(TOK_INVALID);
|
return Token(TOK_INVALID);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user