diff options
author | Arne Döring <arne.doering@gmx.net> | 2019-08-27 23:18:46 +0200 |
---|---|---|
committer | Andreas Rumpf <rumpf_a@web.de> | 2019-08-27 23:18:46 +0200 |
commit | d564130a3b2596161847d695329ad009e693358a (patch) | |
tree | 14ced0de16093871d709b6170a2018bbee897d19 /tools/dochack | |
parent | eff0837ff40e4a5f5659ff02a56d9936bcbd7bcd (diff) | |
download | Nim-d564130a3b2596161847d695329ad009e693358a.tar.gz |
Fix to int to biggest int (#12066)
* fix to(Biggest)Int * kill toFloat magics as well
Diffstat (limited to 'tools/dochack')
-rw-r--r-- | tools/dochack/fuzzysearch.nim | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/tools/dochack/fuzzysearch.nim b/tools/dochack/fuzzysearch.nim index 69f9fce3c..40575b998 100644 --- a/tools/dochack/fuzzysearch.nim +++ b/tools/dochack/fuzzysearch.nim @@ -17,8 +17,8 @@ const ## This is to weight function signatures and descriptions over module titles. -type - ScoreCard = enum +type + ScoreCard = enum StartMatch = -100 ## Start matching. LeadingCharDiff = -3 ## An unmatched, leading character was found. CharDiff = -1 ## An unmatched character was found. @@ -58,19 +58,19 @@ proc fuzzyMatch*(pattern, str: cstring) : tuple[score: int, matched: bool] = if strChar in {'_', ' ', '.'}: strIndex += 1 continue - + # Since this algorithm will be used to search against Nim documentation, # the below logic prioritizes headers. if not headerMatched and strChar == ':': headerMatched = true scoreState = StartMatch - score = toInt(floor(HeadingScaleFactor * toFloat(score))) + score = int(floor(HeadingScaleFactor * float(score))) patIndex = 0 strIndex += 1 continue if strChar == patternChar: - case scoreState + case scoreState of StartMatch, WordBoundryMatch: scoreState = LeadingCharMatch @@ -84,7 +84,7 @@ proc fuzzyMatch*(pattern, str: cstring) : tuple[score: int, matched: bool] = if scoreState == LeadingCharMatch: score += ord(LeadingCharMatch) - + var onBoundary = (patIndex == high(pattern)) if not onBoundary and strIndex < high(str): let @@ -95,7 +95,7 @@ proc fuzzyMatch*(pattern, str: cstring) : tuple[score: int, matched: bool] = nextStrChar notin {'a'..'z'} and nextStrChar != nextPatternChar ) - + if onBoundary: transition(WordBoundryMatch) @@ -115,7 +115,7 @@ proc fuzzyMatch*(pattern, str: cstring) : tuple[score: int, matched: bool] = patIndex += 1 else: - case scoreState + case scoreState of StartMatch: transition(LeadingCharDiff) |