Debian Codegraph @

internal/encoder/string_scan_arm64.go

raw
1 package encoder
2
3 import (
4 "unsafe"
5 )
6
7 // The scan of a string for a byte to escape by NEON, 16 bytes at a time.
8
9 //go:noescape
10 func scanStringNEON(p unsafe.Pointer, n int, tables *nibbleTables) int
11
12 // minSIMDScanLength is the length from which a string is scanned by SIMD.
13 const minSIMDScanLength = 16
14
15 // maxOnePassLength is the length of the longest string which AppendString looks at and copies in one pass:
16 // a longer one is looked at by SIMD, which then costs less, and copied after.
17 const maxOnePassLength = minSIMDScanLength - 1
18
19 // scanBytesSIMD is whether a byte of the n bytes at src is in the tables, by SIMD. The second result is false
20 // if n is small, and the bytes are not looked at. It is inlined, so that AppendString calls the scan itself.
21 func scanBytesSIMD(src unsafe.Pointer, n int, tables *nibbleTables) (bool, bool) {
22 if n < minSIMDScanLength {
23 return false, false
24 }
25 return scanStringNEON(src, n, tables) != 0, true
26 }
27
28 // hasEscapeLoop is false: the loop of the escapes by SIMD is of amd64 only ( see string_scan_amd64.go ).
29 const hasEscapeLoop = false
30
31 // appendEscapedSIMD appends nothing: it is never called on this architecture.
32 func appendEscapedSIMD(buf []byte, _ string, _ *nibbleTables, _ bool) ([]byte, int) {
33 return buf, 0
34 }