From 918ca6151976ab43c330ff9ced9456837601a43a Mon Sep 17 00:00:00 2001 From: David Faure Date: Sun, 12 Oct 2014 13:38:41 +0200 Subject: QTreeView: speed up isRowHidden for the case where no rows are hidden. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit isPersistent(index) is a linear search, which we can avoid altogether (as well as the creation of a persistent model index, is idx is indeed persistent) when the row-hiding feature isn't used at all. Change-Id: I55ef204dd9b79a89d51d5d3aacc1c110d37a4ea0 (cherry picked from qtbase/cd824ee79188b889df85d4d648a625589655e15e) Reviewed-by: Jan Arve Sæther --- src/gui/itemviews/qtreeview_p.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/gui') diff --git a/src/gui/itemviews/qtreeview_p.h b/src/gui/itemviews/qtreeview_p.h index 5d8c4ff949..451e3f80a5 100644 --- a/src/gui/itemviews/qtreeview_p.h +++ b/src/gui/itemviews/qtreeview_p.h @@ -210,6 +210,8 @@ public: QSet hiddenIndexes; inline bool isRowHidden(const QModelIndex &idx) const { + if (hiddenIndexes.isEmpty()) + return false; //We first check if the idx is a QPersistentModelIndex, because creating QPersistentModelIndex is slow return isPersistent(idx) && hiddenIndexes.contains(idx); } -- cgit v1.2.3