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

16
src/result_x86.go Normal file
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
}