MCPcopy Create free account
hub / github.com/dgraph-io/dgraph-benchmarks / readLine

Function readLine

scripts/mutations/mutation.go:78–92  ·  view source on GitHub ↗

Reads a single line from a buffered reader. The line is read into the passed in buffer to minimize allocations. This is the preferred method for loading long lines which could be longer than the buffer size of bufio.Scanner.

(r *bufio.Reader, buf *bytes.Buffer)

Source from the content-addressed store, hash-verified

76// method for loading long lines which could be longer than the buffer
77// size of bufio.Scanner.
78func readLine(r *bufio.Reader, buf *bytes.Buffer) error {
79 isPrefix := true
80 var err error
81 for isPrefix && err == nil {
82 var line []byte
83 // The returned line is an internal buffer in bufio and is only
84 // valid until the next call to ReadLine. It needs to be copied
85 // over to our own buffer.
86 line, isPrefix, err = r.ReadLine()
87 if err == nil {
88 buf.Write(line)
89 }
90 }
91 return err
92}
93
94func main() {
95 flag.Parse()

Callers 1

mainFunction · 0.70

Calls 1

WriteMethod · 0.80

Tested by

no test coverage detected