some minor QRegularExpression usage optimizations and cleanups (#3999)
This commit is contained in:
parent
375df3a6af
commit
902f46bae5
|
@ -307,8 +307,8 @@ void CheckThread::parseClangErrors(const QString &tool, const QString &file0, QS
|
|||
{
|
||||
QList<ErrorItem> errorItems;
|
||||
ErrorItem errorItem;
|
||||
const QRegularExpression r1("^(.+):([0-9]+):([0-9]+): (note|warning|error|fatal error): (.*)$");
|
||||
const QRegularExpression r2("^(.*)\\[([a-zA-Z0-9\\-_\\.]+)\\]$");
|
||||
static const QRegularExpression r1("^(.+):([0-9]+):([0-9]+): (note|warning|error|fatal error): (.*)$");
|
||||
static const QRegularExpression r2("^(.*)\\[([a-zA-Z0-9\\-_\\.]+)\\]$");
|
||||
QTextStream in(&err, QIODevice::ReadOnly);
|
||||
while (!in.atEnd()) {
|
||||
QString line = in.readLine();
|
||||
|
|
|
@ -28,7 +28,7 @@ LibraryAddFunctionDialog::LibraryAddFunctionDialog(QWidget *parent) :
|
|||
mUi(new Ui::LibraryAddFunctionDialog)
|
||||
{
|
||||
mUi->setupUi(this);
|
||||
const QRegularExpression rx(NAMES);
|
||||
static const QRegularExpression rx(NAMES);
|
||||
QValidator *validator = new QRegularExpressionValidator(rx, this);
|
||||
mUi->functionName->setValidator(validator);
|
||||
}
|
||||
|
|
|
@ -262,9 +262,9 @@ void MainWindow::handleCLIParams(const QStringList ¶ms)
|
|||
} else {
|
||||
loadResults(logFile);
|
||||
}
|
||||
} else if ((index = params.indexOf(QRegularExpression(".*\\.cppcheck$", QRegularExpression::CaseInsensitiveOption), 0)) >= 0 && index < params.length() && QFile(params[index]).exists()) {
|
||||
} else if ((index = params.indexOf(QRegularExpression(".*\\.cppcheck$", QRegularExpression::CaseInsensitiveOption))) >= 0 && index < params.length() && QFile(params[index]).exists()) {
|
||||
loadProjectFile(params[index]);
|
||||
} else if ((index = params.indexOf(QRegularExpression(".*\\.xml$", QRegularExpression::CaseInsensitiveOption), 0)) >= 0 && index < params.length() && QFile(params[index]).exists()) {
|
||||
} else if ((index = params.indexOf(QRegularExpression(".*\\.xml$", QRegularExpression::CaseInsensitiveOption))) >= 0 && index < params.length() && QFile(params[index]).exists()) {
|
||||
loadResults(params[index],QDir::currentPath());
|
||||
} else
|
||||
doAnalyzeFiles(params);
|
||||
|
@ -1142,10 +1142,13 @@ void MainWindow::clearResults()
|
|||
if (mProjectFile && !mProjectFile->getBuildDir().isEmpty()) {
|
||||
QDir dir(QFileInfo(mProjectFile->getFilename()).absolutePath() + '/' + mProjectFile->getBuildDir());
|
||||
for (const QString& f: dir.entryList(QDir::Files)) {
|
||||
if (!f.endsWith("files.txt") && !QRegularExpression("^.*.s[0-9]+$").match(f).hasMatch())
|
||||
if (!f.endsWith("files.txt")) {
|
||||
static const QRegularExpression rx("^.*.s[0-9]+$");
|
||||
if (!rx.match(f).hasMatch())
|
||||
dir.remove(f);
|
||||
}
|
||||
}
|
||||
}
|
||||
mUI->mResults->clear(true);
|
||||
Q_ASSERT(false == mUI->mResults->hasResults());
|
||||
enableResultsButtons();
|
||||
|
|
|
@ -406,7 +406,7 @@ QLineSeries *StatsDialog::numberOfReports(const QString &fileName, const QString
|
|||
QTextStream in(&f);
|
||||
while (!in.atEnd()) {
|
||||
QString line = in.readLine();
|
||||
const QRegularExpression rxdate("^\\[(\\d\\d)\\.(\\d\\d)\\.(\\d\\d\\d\\d)\\]$");
|
||||
static const QRegularExpression rxdate("^\\[(\\d\\d)\\.(\\d\\d)\\.(\\d\\d\\d\\d)\\]$");
|
||||
const QRegularExpressionMatch matchRes = rxdate.match(line);
|
||||
if (matchRes.hasMatch()) {
|
||||
int y = matchRes.captured(3).toInt();
|
||||
|
|
|
@ -111,7 +111,10 @@ void MainWindow::load(QTextStream &textStream)
|
|||
if (!errorMessage.isEmpty())
|
||||
mAllErrors << errorMessage;
|
||||
errorMessage.clear();
|
||||
} else if (!url.isEmpty() && QRegularExpression("^.*: (error|warning|style|note):.*$").match(line).hasMatch()) {
|
||||
} else if (!url.isEmpty()) {
|
||||
static const QRegularExpression severityRe("^.*: (error|warning|style|note):.*$");
|
||||
if (severityRe.match(line).hasMatch())
|
||||
continue;
|
||||
const QRegularExpressionMatch matchRes = mVersionRe.match(line);
|
||||
if (matchRes.hasMatch()) {
|
||||
const QString version = matchRes.captured(1);
|
||||
|
|
Loading…
Reference in New Issue