parsing - Is there any benefit to wrapping a bufio.Scanner's reader in a bufio.Reader? -
i'm using bufio.scanner, , i'm not sure if should giving reader wrapped bufio.reader.
i.e., f os.file, should i:
scanner := bufio.newscanner(f) or
scanner := bufio.newscanner(bufio.newreader(f))
from the scan.go source doesn't need pass *bufio.reader: has own buffer, defaulting 4k bufio.reader's buffers do.
// newscanner returns new scanner read r. // split function defaults scanlines. func newscanner(r io.reader) *scanner { return &scanner{ r: r, split: scanlines, maxtokensize: maxscantokensize, buf: make([]byte, 4096), // plausible starting size; needn't large. } }
Comments
Post a Comment