From a4868e994a85ba903db364ad52f1d5957365ed24 Mon Sep 17 00:00:00 2001 From: Martin Baeuml Date: Tue, 9 Apr 2013 00:10:17 +0200 Subject: [PATCH] make index as fast as possible, remove check for special case parent_idx == QModelIndex() This is checked in self.itemFromIndex anyway. --- sloth/annotations/model.py | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/sloth/annotations/model.py b/sloth/annotations/model.py index f3e660b..76d1af5 100644 --- a/sloth/annotations/model.py +++ b/sloth/annotations/model.py @@ -628,12 +628,8 @@ class AnnotationModel(QAbstractItemModel): if parent_idx.isValid() and parent_idx.column() > 0: return QModelIndex() - # Handle root item - if parent_idx == QModelIndex(): - parent = self._root - # Handle normal items - else: - parent = self.itemFromIndex(parent_idx) + # Get parent. This returns the root if parent_idx is invalid. + parent = self.itemFromIndex(parent_idx) if row < 0 or row >= parent.rowCount(): return QModelIndex() if column < 0 or column >= self.columnCount():