Skip to content

Commit

Permalink
Instantiate QRegularExpression instances statically
Browse files Browse the repository at this point in the history
  • Loading branch information
ilya-fedin authored and john-preston committed Dec 29, 2023
1 parent 99afd5a commit afed06a
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions codegen/style/parsed_file.cpp
Expand Up @@ -118,7 +118,8 @@ bool validateAnsiString(const QString &value) {
}

bool validateAlignString(const QString &value) {
return QRegularExpression("^[a-z_]+$").match(value).hasMatch();
static const auto RegExp = QRegularExpression("^[a-z_]+$");
return RegExp.match(value).hasMatch();
}

} // namespace
Expand Down Expand Up @@ -496,8 +497,9 @@ structure::Value ParsedFile::readPositiveValue() {
} else if (numericToken.type == BasicType::Double) {
return { structure::TypeTag::Double, tokenValue(numericToken).toDouble() };
} else if (numericToken.type == BasicType::Name) {
static const auto RegExp = QRegularExpression("^\\d+px$");
auto value = tokenValue(numericToken);
auto match = QRegularExpression("^\\d+px$").match(value);
auto match = RegExp.match(value);
if (match.hasMatch()) {
return { structure::TypeTag::Pixels, base::StringViewMid(value, 0, value.size() - 2).toInt() };
}
Expand Down

0 comments on commit afed06a

Please sign in to comment.