forked from qt-creator/qt-creator
FileSearch: Some micro-optimization
Fixes: QTCREATORBUG-27552 Change-Id: I1b4677af59f335df676d32c2bb0e1dbd5a9dd14b Reviewed-by: <github-actions-qt-creator@cristianadam.eu> Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
@@ -159,8 +159,7 @@ void FileSearch::operator()(QFutureInterface<FileSearchResultList> &futureInterf
|
|||||||
while (!stream.atEnd()) {
|
while (!stream.atEnd()) {
|
||||||
++lineNr;
|
++lineNr;
|
||||||
const QString chunk = stream.readLine();
|
const QString chunk = stream.readLine();
|
||||||
const QString resultItemText = clippedText(chunk, MAX_LINE_SIZE);
|
const int chunkLength = chunk.length();
|
||||||
int chunkLength = chunk.length();
|
|
||||||
const QChar *chunkPtr = chunk.constData();
|
const QChar *chunkPtr = chunk.constData();
|
||||||
const QChar *chunkEnd = chunkPtr + chunkLength - 1;
|
const QChar *chunkEnd = chunkPtr + chunkLength - 1;
|
||||||
for (const QChar *regionPtr = chunkPtr; regionPtr + termMaxIndex <= chunkEnd; ++regionPtr) {
|
for (const QChar *regionPtr = chunkPtr; regionPtr + termMaxIndex <= chunkEnd; ++regionPtr) {
|
||||||
@@ -207,12 +206,17 @@ void FileSearch::operator()(QFutureInterface<FileSearchResultList> &futureInterf
|
|||||||
&& *regionCursor != termDataUpper[regionIndex])
|
&& *regionCursor != termDataUpper[regionIndex])
|
||||||
) {
|
) {
|
||||||
equal = false;
|
equal = false;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (equal) {
|
if (equal) {
|
||||||
results << FileSearchResult(item.filePath, lineNr, resultItemText,
|
const QString resultItemText = clippedText(chunk, MAX_LINE_SIZE);
|
||||||
regionPtr - chunkPtr, termMaxIndex + 1,
|
results << FileSearchResult(item.filePath,
|
||||||
|
lineNr,
|
||||||
|
resultItemText,
|
||||||
|
regionPtr - chunkPtr,
|
||||||
|
termMaxIndex + 1,
|
||||||
QStringList());
|
QStringList());
|
||||||
regionPtr += termMaxIndex; // another +1 done by for-loop
|
regionPtr += termMaxIndex; // another +1 done by for-loop
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user