diff options
author | Olivier Goffart <ogoffart@trolltech.com> | 2010-03-11 10:08:02 (GMT) |
---|---|---|
committer | Olivier Goffart <ogoffart@trolltech.com> | 2010-03-11 10:08:02 (GMT) |
commit | 8404d073d0a8f02d77888496986cba7c0b1b1739 (patch) | |
tree | 89a5532c96a6625f7c387ab7d655a80066cf613c /src/gui/itemviews | |
parent | e788b32e7f059b0f85ca5104279c8f2bcbfff526 (diff) | |
download | Qt-8404d073d0a8f02d77888496986cba7c0b1b1739.zip Qt-8404d073d0a8f02d77888496986cba7c0b1b1739.tar.gz Qt-8404d073d0a8f02d77888496986cba7c0b1b1739.tar.bz2 |
QTreeView: Optimize by avoiding calling detach
QVector::operator[] calls detach. and we should avoid calling it
in a loop.
QVector::at() cannot be used here because we need a non const reference.
Reviewed-by: Gabriel
Diffstat (limited to 'src/gui/itemviews')
-rw-r--r-- | src/gui/itemviews/qtreeview.cpp | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/src/gui/itemviews/qtreeview.cpp b/src/gui/itemviews/qtreeview.cpp index b7a39b1..0a7ffb7 100644 --- a/src/gui/itemviews/qtreeview.cpp +++ b/src/gui/itemviews/qtreeview.cpp @@ -2956,17 +2956,19 @@ void QTreeViewPrivate::expand(int item, bool emitSignal) void QTreeViewPrivate::insertViewItems(int pos, int count, const QTreeViewItem &viewItem) { viewItems.insert(pos, count, viewItem); + QTreeViewItem *items = viewItems.data(); for (int i = pos + count; i < viewItems.count(); i++) - if (viewItems[i].parentItem >= pos) - viewItems[i].parentItem += count; + if (items[i].parentItem >= pos) + items[i].parentItem += count; } void QTreeViewPrivate::removeViewItems(int pos, int count) { viewItems.remove(pos, count); + QTreeViewItem *items = viewItems.data(); for (int i = pos; i < viewItems.count(); i++) - if (viewItems[i].parentItem >= pos) - viewItems[i].parentItem -= count; + if (items[i].parentItem >= pos) + items[i].parentItem -= count; } #if 0 |