From cd824ee79188b889df85d4d648a625589655e15e Mon Sep 17 00:00:00 2001 From: David Faure Date: Sat, 11 Oct 2014 12:54:55 +0200 Subject: [PATCH] QAIV: 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: I07488dddf56e299806cc29749e633da00115fc30 Reviewed-by: Jan Arve Sæther --- src/widgets/itemviews/qtreeview_p.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/widgets/itemviews/qtreeview_p.h b/src/widgets/itemviews/qtreeview_p.h index bc444eb37f..72cb897353 100644 --- a/src/widgets/itemviews/qtreeview_p.h +++ b/src/widgets/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); }