File: valid_support_amd64.go

package info (click to toggle)
golang-github-segmentio-asm 1.2.0%2Bgit20231107.1cfacc8-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 932 kB
  • sloc: asm: 6,093; makefile: 32
file content (21 lines) | stat: -rw-r--r-- 408 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
//go:build !purego
// +build !purego

package utf8

import (
	"github.com/segmentio/asm/cpu"
	"github.com/segmentio/asm/cpu/x86"
)

var noAVX2 = !cpu.X86.Has(x86.AVX2)

// Validate is a more precise version of Valid that also indicates whether the
// input was valid ASCII.
func Validate(p []byte) Validation {
	if noAVX2 || len(p) < 32 {
		return validate(p)
	}
	r := validateAvx(p)
	return Validation(r)
}