mirror of
https://github.com/FiloSottile/age.git
synced 2026-08-31 21:27:13 +00:00
internal/format: buffer newlineWriter writes
Most writes in the cmd/age Writer stack are chunk-sized, so approximately 64KiB. However, the newlineWriter, which splits lines at 64 columns, was doing a Write on the underlying Writer for each line, making chunks effectively 48 bytes (before base64). There is no buffering underneath it, so it was resulting in a lot of write syscalls. Add a reusable bytes.Buffer to buffer the output of each (*newlineWriter).Write call, and Write it all at once on the destination. This makes --armor just 50% slower than plain, instead of 10x. Fixes #167
This commit is contained in:
committed by
Filippo Valsorda
parent
cb4d1de4b7
commit
02ee8b969a
+2
-1
@@ -154,7 +154,8 @@ func main() {
|
||||
}
|
||||
}
|
||||
|
||||
var in, out io.ReadWriter = os.Stdin, os.Stdout
|
||||
var in io.Reader = os.Stdin
|
||||
var out io.Writer = os.Stdout
|
||||
if name := flag.Arg(0); name != "" && name != "-" {
|
||||
f, err := os.Open(name)
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user