From 859ebc4489ce81edc0681881700b0f22754943f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Felix=20Geisendo=CC=88rfer?= Date: Sun, 11 Jan 2015 17:10:07 +0100 Subject: [PATCH] optimize: avoid string cast 43.9 ns/op --- xxd.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/xxd.go b/xxd.go index cb03afb..eb9cb29 100644 --- a/xxd.go +++ b/xxd.go @@ -77,9 +77,9 @@ func XXD(r io.Reader, w io.Writer) error { // Character values b := buf[:n] - for _, c := range b { + for i, c := range b { if c > 0x1f && c < 0x7f { - io.WriteString(w, string(c)) + w.Write(buf[i : i+1]) } else { w.Write(dot) }