Commit 6a08a74a authored by Han-Wen Nienhuys's avatar Han-Wen Nienhuys

benchmark: simplify ReadLines

Change-Id: I683c0f614f67e787229d0754354a25f225184995
parent a8693e36
...@@ -7,32 +7,22 @@ package benchmark ...@@ -7,32 +7,22 @@ package benchmark
// Routines for benchmarking fuse. // Routines for benchmarking fuse.
import ( import (
"bufio" "bytes"
"log" "log"
"os" "os"
) )
func ReadLines(name string) []string { func ReadLines(name string) []string {
f, err := os.Open(name) data, err := os.ReadFile(name)
if err != nil { if err != nil {
log.Fatal("ReadLines: ", err) log.Fatal("ReadFile: ", err)
} }
defer f.Close()
r := bufio.NewReader(f)
l := []string{} var lines []string
for { for _, l := range bytes.Split(data, []byte("\n")) {
line, _, err := r.ReadLine() if len(l) > 0 {
if line == nil || err != nil { lines = append(lines, string(l))
break
} }
fn := string(line)
l = append(l, fn)
}
if len(l) == 0 {
log.Fatal("no files added")
} }
return lines
return l
} }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment