optimize: don't invalidate all line width after each parsing.
This commit is contained in:
parent
8fef396baa
commit
89e2c330e3
|
@ -2221,7 +2221,7 @@ void Editor::onTooltipTimer()
|
|||
void Editor::onEndParsing()
|
||||
{
|
||||
mIdentCache.clear();
|
||||
document()->invalidateAllLineWidth();
|
||||
document()->invalidateAllNonTempLineWidth();
|
||||
invalidate();
|
||||
}
|
||||
|
||||
|
@ -5505,7 +5505,7 @@ void Editor::applyColorScheme(const QString& schemeName)
|
|||
mCurrentHighlighWordForeground = selectedForeground();
|
||||
mCurrentHighlighWordBackground = selectedBackground();
|
||||
}
|
||||
document()->invalidateAllLineWidth();
|
||||
document()->invalidateAllNonTempLineWidth();
|
||||
invalidate();
|
||||
}
|
||||
|
||||
|
|
|
@ -1276,12 +1276,20 @@ void Document::invalidateAllLineWidth()
|
|||
thread->start();
|
||||
}
|
||||
|
||||
void Document::invalidateAllNonTempLineWidth()
|
||||
{
|
||||
QMutexLocker locker(&mMutex);
|
||||
for (PDocumentLine& line:mLines) {
|
||||
if (!line->mIsTempWidth)
|
||||
line->mIsTempWidth;
|
||||
}
|
||||
}
|
||||
|
||||
DocumentLine::DocumentLine(DocumentLine::UpdateWidthFunc updateWidthFunc):
|
||||
mSyntaxState{},
|
||||
mWidth{-1},
|
||||
mIsTempWidth{true},
|
||||
mUpdateWidthFunc{updateWidthFunc},
|
||||
mTimestamp{QDateTime::currentMSecsSinceEpoch()}
|
||||
mUpdateWidthFunc{updateWidthFunc}
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -1324,7 +1332,6 @@ int DocumentLine::width()
|
|||
|
||||
void DocumentLine::setLineText(const QString &newLineText)
|
||||
{
|
||||
mTimestamp = QDateTime::currentMSecsSinceEpoch();
|
||||
mLineText = newLineText;
|
||||
mGlyphStartCharList = calcGlyphStartCharList(newLineText);
|
||||
invalidateWidth();
|
||||
|
|
|
@ -179,7 +179,6 @@ private:
|
|||
int mWidth;
|
||||
bool mIsTempWidth;
|
||||
UpdateWidthFunc mUpdateWidthFunc;
|
||||
qint64 mTimestamp;
|
||||
friend class Document;
|
||||
friend class FindMaxLineWidthThread;
|
||||
};
|
||||
|
@ -637,7 +636,7 @@ public:
|
|||
void setForceMonospace(bool newForceMonospace);
|
||||
|
||||
public slots:
|
||||
void invalidateAllLineWidth();
|
||||
void invalidateAllNonTempLineWidth();
|
||||
|
||||
signals:
|
||||
void changed();
|
||||
|
@ -659,6 +658,7 @@ protected:
|
|||
emit lineWidthUpdateNeeded(line);
|
||||
}
|
||||
private:
|
||||
void invalidateAllLineWidth();
|
||||
bool lineWidthValid(int line);
|
||||
void beginSetLinesWidth();
|
||||
void endSetLinesWidth();
|
||||
|
|
|
@ -4718,7 +4718,7 @@ void QSynEdit::setSyntaxer(const PSyntaxer &syntaxer)
|
|||
reparseDocument();
|
||||
mDocument->endUpdate();
|
||||
}
|
||||
mDocument->invalidateAllLineWidth();
|
||||
mDocument->invalidateAllNonTempLineWidth();
|
||||
invalidate();
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue