Reduced memory usage

This commit is contained in:
Eduard Urbach 2024-06-20 11:29:39 +02:00
parent 9b50c917e9
commit ff2a43e593
Signed by: akyoto
GPG Key ID: C874F672B1AF20C0
2 changed files with 9 additions and 3 deletions

View File

@ -21,3 +21,11 @@ func BenchmarkExpressions(b *testing.B) {
compiler.Run() compiler.Run()
} }
} }
func BenchmarkHello(b *testing.B) {
compiler := build.New("examples/hello")
for i := 0; i < b.N; i++ {
compiler.Run()
}
}

View File

@ -5,8 +5,6 @@ import (
"unsafe" "unsafe"
) )
const blockSize = 4096
// Walk calls your callback function for every file name inside the directory. // Walk calls your callback function for every file name inside the directory.
// It doesn't distinguish between files and directories. // It doesn't distinguish between files and directories.
func Walk(directory string, callBack func(string)) error { func Walk(directory string, callBack func(string)) error {
@ -17,7 +15,7 @@ func Walk(directory string, callBack func(string)) error {
} }
defer syscall.Close(fd) defer syscall.Close(fd)
buffer := make([]byte, blockSize) buffer := make([]byte, 1024)
for { for {
n, err := syscall.ReadDirent(fd, buffer) n, err := syscall.ReadDirent(fd, buffer)