From c2d800d607ad655efbe507df610097512d83eb0f Mon Sep 17 00:00:00 2001 From: jim teeuwen Date: Thu, 14 Jun 2012 11:20:10 +0200 Subject: [PATCH] Cosmetic fixes. --- translate.go | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/translate.go b/translate.go index ac47a03..18e529c 100644 --- a/translate.go +++ b/translate.go @@ -50,13 +50,16 @@ func %s() []byte {`, funcname, funcname) if uncompressed { fmt.Fprintf(output, ` + // This bit of black magic ensures we do not get + // unneccesary memcpy's and can read directly from + // the .rodata section. var empty [0]byte sx := (*reflect.StringHeader)(unsafe.Pointer(&_%s)) b := empty[:] bx := (*reflect.SliceHeader)(unsafe.Pointer(&b)) bx.Data = sx.Data - bx.Len = len(_%s) - bx.Cap = bx.Len + bx.Len = len(_%s) + bx.Cap = bx.Len return b`, funcname, funcname) } else { fmt.Fprintf(output, ` @@ -68,8 +71,8 @@ func %s() []byte {`, funcname, funcname) b := empty[:] bx := (*reflect.SliceHeader)(unsafe.Pointer(&b)) bx.Data = sx.Data - bx.Len = len(_%s) - bx.Cap = bx.Len + bx.Len = len(_%s) + bx.Cap = bx.Len gz, err := gzip.NewReader(bytes.NewBuffer(b))