From 166efcbda9b1e9c32378b3226f8054f4f7109c22 Mon Sep 17 00:00:00 2001 From: Stephen Blott Date: Sun, 24 Apr 2016 10:35:46 +0100 Subject: Filtered hints; tweak scoring. Re-order the tests such that we don't even do the scoring if there are no query (search) terms. This might (very) marginally speed up link-hints launch. --- content_scripts/link_hints.coffee | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/content_scripts/link_hints.coffee b/content_scripts/link_hints.coffee index f44550bc..7153338b 100644 --- a/content_scripts/link_hints.coffee +++ b/content_scripts/link_hints.coffee @@ -481,7 +481,7 @@ class FilterHints hintMarkers .filter (linkMarker) => linkMarker.score = scoreFunction linkMarker - 0 < linkMarker.score or 0 == @linkTextKeystrokeQueue.length + 0 == @linkTextKeystrokeQueue.length or 0 < linkMarker.score .sort (a, b) -> if b.score == a.score then b.stableSortCount - a.stableSortCount else b.score - a.score @@ -501,6 +501,7 @@ class FilterHints scoreLinkHint: (linkSearchString) -> searchWords = linkSearchString.trim().toLowerCase().split @splitRegexp (linkMarker) => + return 0 unless 0 < searchWords.length # We only keep non-empty link words. Empty link words cannot be matched, and leading empty link words # disrupt the scoring of matches at the start of the text. linkWords = linkMarker.linkWords ?= linkMarker.linkText.toLowerCase().split(@splitRegexp).filter (term) -> term -- cgit v1.2.3