From 6b4805ca1a1b0758363d1bb8c4c996730e19dc5a Mon Sep 17 00:00:00 2001 From: Junegunn Choi Date: Sat, 26 Aug 2017 21:58:18 +0900 Subject: Optimize rank comparison on x86 (little-endian) --- src/result.go | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-) (limited to 'src/result.go') diff --git a/src/result.go b/src/result.go index 58cbafd7..289d83a0 100644 --- a/src/result.go +++ b/src/result.go @@ -70,7 +70,7 @@ func buildResult(item *Item, offsets []Offset, score int) Result { } } } - result.points[idx] = val + result.points[3-idx] = val } return result @@ -224,16 +224,3 @@ func (a ByRelevanceTac) Swap(i, j int) { func (a ByRelevanceTac) Less(i, j int) bool { return compareRanks(a[i], a[j], true) } - -func compareRanks(irank Result, jrank Result, tac bool) bool { - for idx := 0; idx < 4; idx++ { - left := irank.points[idx] - right := jrank.points[idx] - if left < right { - return true - } else if left > right { - return false - } - } - return (irank.item.Index() <= jrank.item.Index()) != tac -} -- cgit v1.2.3