Source File
string_scan_amd64.go
Belonging Package
github.com/goccy/go-json/internal/decoder
package decoderimport ()// hasStringSIMD is whether indexStringSpecial scans: whether the CPU has AVX2.var hasStringSIMD = runtime.HasAVX2//go:noescapefunc indexStringSpecialAVX2( unsafe.Pointer, int) ( int, uint64)// minStringSIMDLength is the number of the bytes from which the rest of a string is scanned by SIMD, after its// first words: the call and the setup of the registers cost about as much as a few words of the scalar scan.const minStringSIMDLength = 32// indexStringSpecial returns the index of the first byte of the n bytes at p which is a quote, a backslash or a// control character, or n if there is none, and high, which is msb if a byte before it is not ASCII and else 0,// as the scan by words accumulates it. The last result is false if the CPU has no SIMD scan or n is less than// minStringSIMDLength: nothing is scanned.func indexStringSpecial( unsafe.Pointer, int) (int, uint64, bool) {if !runtime.HasAVX2 || < minStringSIMDLength {return 0, 0, false}, := indexStringSpecialAVX2(, )if != 0 {// the scan by AVX2 has a bit for every byte which is not ASCII: the callers look at the top bits of bytes.= msb}return , , true}
![]() |
The pages are generated with Golds v0.8.7. (GOOS=linux GOARCH=amd64) Golds is a Go 101 project developed by Tapir Liu. PR and bug reports are welcome and can be submitted to the issue list. Please follow @zigo_101 (reachable from the left QR code) to get the latest news of Golds. |