From 88b3f468d149c4faba5410be5dfaa2ce50111616 Mon Sep 17 00:00:00 2001 From: Eduard Urbach Date: Fri, 14 Feb 2025 16:46:36 +0100 Subject: [PATCH] Updated Go version --- go.mod | 2 +- src/asmc/Finalize.go | 2 +- src/compiler/Compile.go | 4 ++-- src/compiler/PrintInstructions.go | 2 +- src/expression/bench_test.go | 2 +- src/scanner/scanImport.go | 2 +- src/token/bench_test.go | 2 +- tests/examples_test.go | 2 +- tests/programs_test.go | 2 +- 9 files changed, 10 insertions(+), 10 deletions(-) diff --git a/go.mod b/go.mod index 3a61a1f..c74451e 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module git.akyoto.dev/cli/q -go 1.23 +go 1.24 require ( git.akyoto.dev/go/assert v0.1.3 diff --git a/src/asmc/Finalize.go b/src/asmc/Finalize.go index ff47fb3..71bb996 100644 --- a/src/asmc/Finalize.go +++ b/src/asmc/Finalize.go @@ -16,7 +16,7 @@ func Finalize(a asm.Assembler, dlls dll.List) ([]byte, []byte) { c := compiler{ code: make([]byte, 0, len(a.Instructions)*8), - codeLabels: map[string]Address{}, + codeLabels: make(map[string]Address, 32), codeStart: codeOffset(), data: data, dataLabels: dataLabels, diff --git a/src/compiler/Compile.go b/src/compiler/Compile.go index 9a7f4e6..d66ce52 100644 --- a/src/compiler/Compile.go +++ b/src/compiler/Compile.go @@ -11,8 +11,8 @@ import ( func Compile(files <-chan *fs.File, functions <-chan *core.Function, structs <-chan *types.Struct, errs <-chan error) (Result, error) { result := Result{} allFiles := make([]*fs.File, 0, 8) - allFunctions := map[string]*core.Function{} - allStructs := map[string]*types.Struct{} + allFunctions := make(map[string]*core.Function, 32) + allStructs := make(map[string]*types.Struct, 8) for functions != nil || structs != nil || files != nil || errs != nil { select { diff --git a/src/compiler/PrintInstructions.go b/src/compiler/PrintInstructions.go index 686aa63..3d92da2 100644 --- a/src/compiler/PrintInstructions.go +++ b/src/compiler/PrintInstructions.go @@ -4,7 +4,7 @@ import "git.akyoto.dev/cli/q/src/core" // PrintInstructions prints out the generated instructions. func (r *Result) PrintInstructions() { - r.eachFunction(r.Main, map[*core.Function]bool{}, func(f *core.Function) { + r.eachFunction(r.Main, make(map[*core.Function]bool, len(r.Functions)), func(f *core.Function) { f.PrintInstructions() }) } diff --git a/src/expression/bench_test.go b/src/expression/bench_test.go index ec63729..7353cce 100644 --- a/src/expression/bench_test.go +++ b/src/expression/bench_test.go @@ -11,7 +11,7 @@ func BenchmarkExpression(b *testing.B) { src := []byte("(1+2-3*4)+(5*6-7+8)") tokens := token.Tokenize(src) - for range b.N { + for b.Loop() { expression.Parse(tokens) } } diff --git a/src/scanner/scanImport.go b/src/scanner/scanImport.go index 710a76a..47ed367 100644 --- a/src/scanner/scanImport.go +++ b/src/scanner/scanImport.go @@ -20,7 +20,7 @@ func (s *Scanner) scanImport(file *fs.File, tokens token.List, i int) (int, erro packageName := tokens[i].Text(file.Bytes) if file.Imports == nil { - file.Imports = map[string]*fs.Import{} + file.Imports = make(map[string]*fs.Import, 4) } fullPath := filepath.Join(config.Library, packageName) diff --git a/src/token/bench_test.go b/src/token/bench_test.go index 3c54881..6004fa3 100644 --- a/src/token/bench_test.go +++ b/src/token/bench_test.go @@ -17,7 +17,7 @@ func bench(n int) func(b *testing.B) { return func(b *testing.B) { input := bytes.Repeat(line, n) - for range b.N { + for b.Loop() { token.Tokenize(input) } } diff --git a/tests/examples_test.go b/tests/examples_test.go index 7373867..5096c62 100644 --- a/tests/examples_test.go +++ b/tests/examples_test.go @@ -49,7 +49,7 @@ func BenchmarkExamples(b *testing.B) { b.Run(test.Name, func(b *testing.B) { compiler := build.New(filepath.Join("..", "examples", test.Name)) - for range b.N { + for b.Loop() { _, err := compiler.Run() assert.Nil(b, err) } diff --git a/tests/programs_test.go b/tests/programs_test.go index d5a1eca..f3a13cb 100644 --- a/tests/programs_test.go +++ b/tests/programs_test.go @@ -86,7 +86,7 @@ func BenchmarkPrograms(b *testing.B) { b.Run(test.Name, func(b *testing.B) { compiler := build.New(filepath.Join("programs", test.Name+".q")) - for range b.N { + for b.Loop() { _, err := compiler.Run() assert.Nil(b, err) }