style: modernize to splitseq, cut, min, maps.copy and range-over-int

This commit is contained in:
2026-08-29 16:04:32 +02:00
parent eacf33d0f7
commit 9beff4ae85
40 changed files with 90 additions and 234 deletions
+1 -4
View File
@@ -54,10 +54,7 @@ func TestGroundTruthARM64(t *testing.T) {
// The Go toolchain may add zero padding at the end of
// functions. Compare up to the shorter length, then
// verify any trailing bytes are zero.
cmpLen := len(gasmCode)
if len(goCode) < cmpLen {
cmpLen = len(goCode)
}
cmpLen := min(len(goCode), len(gasmCode))
if !bytes.Equal(gasmCode[:cmpLen], goCode[:cmpLen]) {
t.Errorf("%s: MISMATCH gasm=%d go=%d bytes\n%s", fn.Name, len(gasmCode), len(goCode), diffHex(gasmCode, goCode))
continue
+2 -2
View File
@@ -25,7 +25,7 @@ func ParseBufSpec(spec string) ([]BufSpec, error) {
return nil, nil
}
var out []BufSpec
for _, part := range strings.Split(spec, ",") {
for part := range strings.SplitSeq(spec, ",") {
fields := strings.SplitN(part, ":", 3)
if len(fields) != 3 {
return nil, fmt.Errorf("verify: invalid buffer spec %q (expected name:size:pattern)", part)
@@ -185,7 +185,7 @@ func ParseScalarArgs(spec string) (map[string]uint64, error) {
if strings.TrimSpace(spec) == "" {
return out, nil
}
for _, part := range strings.Split(spec, ",") {
for part := range strings.SplitSeq(spec, ",") {
part = strings.TrimSpace(part)
if part == "" {
continue
+3 -6
View File
@@ -61,8 +61,8 @@ func parseFuncSig(comment string) (funcSig, bool) {
if m == nil {
return funcSig{}, false
}
sig := funcSig{name: m[1]}
sig.params = parseParams(m[2])
sig := funcSig{name: m[1],
params: parseParams(m[2])}
// Results may be "(a int, b int)" or "int" or "(int, error)".
res := strings.TrimSpace(m[3])
res = strings.TrimPrefix(res, "(")
@@ -271,10 +271,7 @@ func genDualArgs(rng *rand.Rand, sig funcSig, argSize int) (gasmArgs, goArgs []b
case strings.HasPrefix(p.typ, "*["):
nElem := arrayLen(p.typ)
elem := elemSizeFor("[]" + p.typ[strings.Index(p.typ, "]")+1:])
size := nElem * elem
if size < 8 {
size = 8
}
size := max(nElem*elem, 8)
buf1 := make([]byte, size)
buf2 := make([]byte, size)
rng.Read(buf1)
+1 -1
View File
@@ -169,7 +169,7 @@ func extractGOOBJCode(data []byte) (map[string][]byte, error) {
result := make(map[string][]byte)
const kindSTEXT = 1
for s := 0; s < nSyms; s++ {
for s := range nSyms {
x := nonpkg[s*symSize:]
nameLen := le.Uint32(x[0:])
nameOff := le.Uint32(x[4:])
+1 -4
View File
@@ -76,10 +76,7 @@ func maskRelocs(code []byte, relocs []asm.Reloc) []byte {
func diffHex(a, b []byte) string {
var out bytes.Buffer
n := len(a)
if len(b) > n {
n = len(b)
}
n := max(len(b), len(a))
for i := 0; i < n; i += 4 {
ab, bb := "??", "??"
if i+4 <= len(a) {
+2 -2
View File
@@ -32,8 +32,8 @@ func ParseFuncSig(comment string) (FuncSig, bool) {
if m == nil {
return FuncSig{}, false
}
sig := FuncSig{Name: m[1]}
sig.Params = parseParamsExported(m[2])
sig := FuncSig{Name: m[1],
Params: parseParamsExported(m[2])}
// Results may be "(a int, b int)" or "int" or "(int, error)".
res := strings.TrimSpace(m[3])
res = strings.TrimPrefix(res, "(")