forked from qt-creator/qt-creator
TextEditor: make it obvious that formats are consumed by setExtraFormats
... by transforming the parameter to an r value and pass the argument by std::move. Change-Id: I6949ee6bbac7d8675fdbbcb62bb4f4c394bb395f Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
This commit is contained in:
@@ -112,7 +112,7 @@ void SemanticHighlighter::incrementalApplyExtraAdditionalFormats(
|
|||||||
if (nextBlockNumber != blockNumber)
|
if (nextBlockNumber != blockNumber)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
highlighter->setExtraFormats(b, formats);
|
highlighter->setExtraFormats(b, std::move(formats));
|
||||||
b = b.next();
|
b = b.next();
|
||||||
++currentBlockNumber;
|
++currentBlockNumber;
|
||||||
}
|
}
|
||||||
|
@@ -662,10 +662,10 @@ static bool byStartOfRange(const QTextLayout::FormatRange &range, const QTextLay
|
|||||||
return range.start < other.start;
|
return range.start < other.start;
|
||||||
}
|
}
|
||||||
|
|
||||||
// The formats is passed in by reference in order to prevent unnecessary copying of its items.
|
// The formats is passed in by rvalue reference in order to prevent unnecessary copying of its items.
|
||||||
// After this function returns, the list is modified, and should be considered invalidated!
|
// After this function returns, the list is modified, and should be considered invalidated!
|
||||||
void SyntaxHighlighter::setExtraFormats(const QTextBlock &block,
|
void SyntaxHighlighter::setExtraFormats(const QTextBlock &block,
|
||||||
QVector<QTextLayout::FormatRange> &formats)
|
QVector<QTextLayout::FormatRange> &&formats)
|
||||||
{
|
{
|
||||||
Q_D(SyntaxHighlighter);
|
Q_D(SyntaxHighlighter);
|
||||||
|
|
||||||
|
@@ -63,7 +63,7 @@ public:
|
|||||||
void setDocument(QTextDocument *doc);
|
void setDocument(QTextDocument *doc);
|
||||||
QTextDocument *document() const;
|
QTextDocument *document() const;
|
||||||
|
|
||||||
void setExtraFormats(const QTextBlock &block, QVector<QTextLayout::FormatRange> &formats);
|
void setExtraFormats(const QTextBlock &block, QVector<QTextLayout::FormatRange> &&formats);
|
||||||
void clearExtraFormats(const QTextBlock &block);
|
void clearExtraFormats(const QTextBlock &block);
|
||||||
|
|
||||||
static QList<QColor> generateColors(int n, const QColor &background);
|
static QList<QColor> generateColors(int n, const QColor &background);
|
||||||
|
Reference in New Issue
Block a user