Add not_index_byte and not_index_byte2 functions to simdstring package

Fixes #9646
This commit is contained in:
copilot-swe-agent[bot] 2026-03-12 07:39:02 +00:00 committed by Kovid Goyal
parent d8af7e2c88
commit f4bf9cf1c9
No known key found for this signature in database
GPG key ID: 06BC317B515ACE7C
5 changed files with 231 additions and 0 deletions

View file

@ -64,3 +64,45 @@ func BenchmarkIndexByte2(b *testing.B) {
t(pos, "scalar")
}
}
func BenchmarkNotIndexByte(b *testing.B) {
t := func(pos int, which string) {
// Fill with 'a' and place 'q' (a non-matching byte) at the target position
data := haystack('a', 'q', pos)
f := NotIndexByte
switch which {
case "scalar":
f = not_index_byte_scalar
}
b.Run(fmt.Sprintf("%s_sz=%d", which, pos), func(b *testing.B) {
for b.Loop() {
f(data, 'a')
}
})
}
for _, pos := range sizes {
t(pos, "simdstring")
t(pos, "scalar")
}
}
func BenchmarkNotIndexByte2(b *testing.B) {
t := func(pos int, which string) {
// Fill with 'a' and place 'q' (neither 'a' nor 'x') at the target position
data := haystack('a', 'q', pos)
f := NotIndexByte2
switch which {
case "scalar":
f = not_index_byte2_scalar
}
b.Run(fmt.Sprintf("%s_sz=%d", which, pos), func(b *testing.B) {
for b.Loop() {
f(data, 'a', 'x')
}
})
}
for _, pos := range sizes {
t(pos, "simdstring")
t(pos, "scalar")
}
}