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
// Routines for benchmarking fuse.
import (
"bufio"
"bytes"
"log"
"os"
)
func ReadLines(name string) []string {
f, err := os.Open(name)
data, err := os.ReadFile(name)
if err != nil {
log.Fatal("ReadLines: ", err)
log.Fatal("ReadFile: ", err)
}
defer f.Close()
r := bufio.NewReader(f)
l := []string{}
for {
line, _, err := r.ReadLine()
if line == nil || err != nil {
break
var lines []string
for _, l := range bytes.Split(data, []byte("\n")) {
if len(l) > 0 {
lines = append(lines, string(l))
}
fn := string(line)
l = append(l, fn)
}
if len(l) == 0 {
log.Fatal("no files added")
}
return l
return lines
}
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