From 11253571c435a4be524f8493be10a38397107895 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Tue, 18 May 2021 20:27:46 +0530 Subject: [PATCH] micro-optimization --- src/pyj/read_book/search_worker.pyj | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/pyj/read_book/search_worker.pyj b/src/pyj/read_book/search_worker.pyj index 2b2bbf45ab..53534ba7e5 100644 --- a/src/pyj/read_book/search_worker.pyj +++ b/src/pyj/read_book/search_worker.pyj @@ -77,9 +77,9 @@ class ToCOffsetMap: while parent?: ancestors.push(parent) parent = self.parent_map[parent.id] - if len(ancestors) > 1: - ancestors.pop() # root node - for v'var i = ancestors.length; i-- > 0;': + if ancestors.length > 1: + # last item in ancestors is the root node + for v'var i = ancestors.length - 1; i-- > 0;': ans.push(ancestors[i].id) ans.push(node.id) return ans