refs #710 Simple algorithms to replace several regular expressions.

This commit is contained in:
Mathew Sutcliffe
2016-08-30 04:02:00 +01:00
parent d2aa2e9c1c
commit 87eeac4e15
13 changed files with 218 additions and 57 deletions

View File

@@ -230,7 +230,7 @@ namespace BlackCore
CLogMessage(this).info("VATSIM file has same content, skipped");
return;
}
const QStringList lines = dataFileData.split(QRegExp("[\r\n]"), QString::SkipEmptyParts);
const QList<QStringRef> lines = splitLinesRefs(dataFileData);
if (lines.isEmpty()) { return; }
// build on local vars for thread safety
@@ -243,7 +243,9 @@ namespace BlackCore
QStringList clientSectionAttributes;
Section section = SectionNone;
for (const QString &cl : lines)
QString currentLine; // declared outside of the for loop, to amortize the cost of allocation
for (QStringRef clRef : lines)
{
if (this->isAbandoned())
{
@@ -253,7 +255,7 @@ namespace BlackCore
}
// parse lines
QString currentLine(cl.trimmed());
currentLine = clRef.toString().trimmed();
if (currentLine.isEmpty()) continue;
if (currentLine.startsWith(";"))
{

View File

@@ -102,14 +102,15 @@ namespace BlackCore
nwReply->close(); // close asap
if (dataFileData.isEmpty()) return;
const QStringList lines = dataFileData.split(QRegExp("[\r\n]"), QString::SkipEmptyParts);
const QList<QStringRef> lines = splitLinesRefs(dataFileData);
if (lines.isEmpty()) { return; }
CUrlList dataFileUrls;
CUrlList serverFileUrls;
CUrlList metarFileUrls;
for (const QString &cl : lines)
QString currentLine; // declared outside of the for loop, to amortize the cost of allocation
for (QStringRef clRef : lines)
{
if (this->isAbandoned())
{
@@ -119,7 +120,7 @@ namespace BlackCore
}
// parse lines
const QString currentLine(cl.trimmed());
currentLine = clRef.toString().trimmed();
if (currentLine.isEmpty()) { continue; }
if (currentLine.startsWith(";")) { continue; }
if (!currentLine.contains("=")) { continue; }