From 2501b5561ee2ea17876a11f5024a76a547dba73e Mon Sep 17 00:00:00 2001 From: Deimos Date: Mon, 3 Sep 2018 17:30:08 -0600 Subject: [PATCH] Skip comment tree sorting if tree is empty --- tildes/tildes/models/comment/comment_tree.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tildes/tildes/models/comment/comment_tree.py b/tildes/tildes/models/comment/comment_tree.py index 7d95a3c..424beb0 100644 --- a/tildes/tildes/models/comment/comment_tree.py +++ b/tildes/tildes/models/comment/comment_tree.py @@ -41,7 +41,7 @@ class CommentTree: # no need to sort again if that's the desired sorting. Note also that because # _sort_tree() uses sorted() which is a stable sort, this means that the # "secondary sort" will always be by posting time as well. - if sort != CommentSortOption.POSTED: + if self.tree and sort != CommentSortOption.POSTED: with self._sorting_histogram().time(): self.tree = self._sort_tree(self.tree, self.sort)