m/fzf
1
0
mirror of https://github.com/junegunn/fzf.git synced 2025-11-16 23:33:39 -05:00

Optimize rank comparison on x86 (little-endian)

This commit is contained in:
Junegunn Choi
2017-08-26 21:58:18 +09:00
parent 159699b5d7
commit 6b4805ca1a
4 changed files with 37 additions and 18 deletions

View File

@@ -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
}