Optimize rank comparison on x86 (little-endian)

This commit is contained in:
Junegunn Choi committed 2017-08-27 01:46:11 +09:00
1 parent 159699b5d7
commit 6b4805ca1a
4 files changed
+37 -18

No files matched your search

+16
View File
@@ -0,0 +1,16 @@
// +build 386 amd64
package fzf
import "unsafe"
func compareRanks(irank Result, jrank Result, tac bool) bool {
left := *(*uint64)(unsafe.Pointer(&irank.points[0]))
right := *(*uint64)(unsafe.Pointer(&jrank.points[0]))
if left < right {
return true
} else if left > right {
return false
}
return (irank.item.Index() <= jrank.item.Index()) != tac
}