mirror of
https://github.com/junegunn/fzf.git
synced 2026-03-08 07:57:04 +08:00
Use SIMD to search for two bytes simultaneously, replacing the two-pass bytes.IndexByte approach in trySkip and the scalar backward loop in asciiFuzzyIndex. AVX2+SSE2 on amd64, NEON on arm64, with scalar fallback for other architectures. === query: 'l' === [all] baseline: 100.61ms current: 98.88ms (+1.7%) matches: 5069891 (94.78%) [1T] baseline: 889.28ms current: 852.71ms (+4.1%) matches: 5069891 (94.78%) === query: 'lin' === [all] baseline: 281.31ms current: 269.35ms (+4.3%) matches: 3516507 (65.74%) [1T] baseline: 2266.51ms current: 2238.24ms (+1.2%) matches: 3516507 (65.74%) === query: 'linux' === [all] baseline: 69.94ms current: 68.33ms (+2.3%) matches: 307229 (5.74%) [1T] baseline: 642.66ms current: 589.10ms (+8.3%) matches: 307229 (5.74%) === query: 'linuxlinux' === [all] baseline: 39.56ms current: 35.48ms (+10.3%) matches: 12230 (0.23%) [1T] baseline: 367.88ms current: 333.49ms (+9.3%) matches: 12230 (0.23%) === query: 'linuxlinuxlinux' === [all] baseline: 36.22ms current: 31.59ms (+12.8%) matches: 865 (0.02%) [1T] baseline: 339.48ms current: 293.02ms (+13.7%) matches: 865 (0.02%)
18 lines
531 B
Go
18 lines
531 B
Go
//go:build arm64
|
|
|
|
package algo
|
|
|
|
// indexByteTwo returns the index of the first occurrence of b1 or b2 in s,
|
|
// or -1 if neither is present. Implemented in assembly using ARM64 NEON
|
|
// to search for both bytes in a single pass.
|
|
//
|
|
//go:noescape
|
|
func indexByteTwo(s []byte, b1, b2 byte) int
|
|
|
|
// lastIndexByteTwo returns the index of the last occurrence of b1 or b2 in s,
|
|
// or -1 if neither is present. Implemented in assembly using ARM64 NEON,
|
|
// scanning backward.
|
|
//
|
|
//go:noescape
|
|
func lastIndexByteTwo(s []byte, b1, b2 byte) int
|