From 2401c53250b98cca4b70a920c58782c52cc685dd Mon Sep 17 00:00:00 2001 From: Stephen Blott Date: Fri, 2 Nov 2012 12:33:08 +0000 Subject: Bookmark traversal fixes. Changes: - use natural order for bookmark traversal - eliminate use of O(N^2) `shift` --- background_scripts/completion.coffee | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/background_scripts/completion.coffee b/background_scripts/completion.coffee index f7313756..79f31073 100644 --- a/background_scripts/completion.coffee +++ b/background_scripts/completion.coffee @@ -112,11 +112,11 @@ class BookmarkCompleter # Traverses the bookmark hierarchy, and retuns a flattened list of all bookmarks in the tree. traverseBookmarks: (bookmarks) -> results = [] - toVisit = bookmarks + toVisit = bookmarks.reverse() while toVisit.length > 0 - bookmark = toVisit.shift() + bookmark = toVisit.pop() results.push(bookmark) - toVisit.push.apply(toVisit, bookmark.children) if (bookmark.children) + toVisit.push.apply(toVisit, bookmark.children.reverse()) if (bookmark.children) results computeRelevancy: (suggestion) -> -- cgit v1.2.3