diff options
author | Fumitoshi Ukai <fumitoshi.ukai@gmail.com> | 2015-06-19 11:07:07 +0900 |
---|---|---|
committer | Fumitoshi Ukai <fumitoshi.ukai@gmail.com> | 2015-06-19 11:07:07 +0900 |
commit | a44b766d8ecf8b92706bd78d54e86cccdc4b0553 (patch) | |
tree | 47a0a121a53f576d977849fcab91c31f50ccacf0 /func.go | |
parent | cc8d0cd2fcb2b46133653f97b3f99640bd095fa4 (diff) | |
download | android_build_kati-a44b766d8ecf8b92706bd78d54e86cccdc4b0553.tar.gz android_build_kati-a44b766d8ecf8b92706bd78d54e86cccdc4b0553.tar.bz2 android_build_kati-a44b766d8ecf8b92706bd78d54e86cccdc4b0553.zip |
reduce allocation in funcStrip
benchmark old ns/op new ns/op delta
BenchmarkFuncStrip 468 334 -28.63%
benchmark old allocs new allocs delta
BenchmarkFuncStrip 1 0 -100.00%
benchmark old bytes new bytes delta
BenchmarkFuncStrip 32 0 -100.00%
Diffstat (limited to 'func.go')
-rw-r--r-- | func.go | 8 |
1 files changed, 6 insertions, 2 deletions
@@ -195,9 +195,13 @@ func (f *funcStrip) Eval(w io.Writer, ev *Evaluator) { abuf := newBuf() f.args[1].Eval(abuf, ev) ws := newWordScanner(abuf.Bytes()) - sw := ssvWriter{w: w} + space := false for ws.Scan() { - sw.Write(ws.Bytes()) + if space { + writeByte(w, ' ') + } + w.Write(ws.Bytes()) + space = true } freeBuf(abuf) } |