diff options
author | Langonda Agag <namezero@afim.info> | 2019-11-25 07:25:46 +0000 |
---|---|---|
committer | Langonda Agag <namezero@afim.info> | 2019-11-25 08:44:56 +0000 |
commit | 0e0793ca590439bd437310f1e80507d21be3f14d (patch) | |
tree | 8f9d22839d67dc62189b9127a477a43833094c1c /src/gui/text/qsyntaxhighlighter.h | |
parent | 59a705e3710b0ba93bb698e3223241cfac932948 (diff) |
Improve QTextDocumentPrivate cursor performance
The cursors in QTextDocumentPrivate are held in a QList.
This becomes a serious performance problem with lots of
extra selections due to a call to
QTextDocumentPrivate::removeCursor() from the QTextCursor
destructor.
Given the following test program:
QPlainTextEdit *editor = ...
std::list< QTextCursor> list;
for(int i = 0; i < 100000; ++i) {
QTextCursor c(editor->document());
c.setPosition(std::rand()%100);
list.push_front(c);
}
list.clear(); // <-- clear calls hangs for 3+ seconds
// due to time spent in
// QTextDocumentPrivate::removeCursor()
// due to QList::removeAll() call
Note the push_front because it exacerbates the issue because
the entire list will be traversed.
The change submitted changes the structure to a set,
removing the issue.
In theory, this limits that a cursors cannot be in the
structure twice, but this neither happens nor would it make sense.
Change-Id: I817dc5d1bda1d98c6725a531b32d1c711a029a34
Reviewed-by: Langonda Agag <namezero@afim.info>
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
Reviewed-by: Jesus Fernandez <jsfdez@gmail.com>
Diffstat (limited to 'src/gui/text/qsyntaxhighlighter.h')
0 files changed, 0 insertions, 0 deletions