Updated Go version

This commit is contained in:
Eduard Urbach 2025-02-14 16:46:36 +01:00
parent d589b02570
commit 88b3f468d1
Signed by: akyoto
GPG Key ID: C874F672B1AF20C0
9 changed files with 10 additions and 10 deletions

2
go.mod
View File

@ -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

View File

@ -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,

View File

@ -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 {

View File

@ -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()
})
}

View File

@ -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)
}
}

View File

@ -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)

View File

@ -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)
}
}

View File

@ -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)
}

View File

@ -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)
}