From 8e26a644caa8644d3c1e3794cbd6b3971f505544 Mon Sep 17 00:00:00 2001 From: Nigel Tao Date: Wed, 18 May 2011 10:56:20 -0700 Subject: [PATCH] image/jpeg: make writeDQT do fewer array copies. R=rsc, r CC=golang-dev https://golang.org/cl/4536069 --- src/pkg/image/jpeg/writer.go | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/pkg/image/jpeg/writer.go b/src/pkg/image/jpeg/writer.go index 4a861b39519..c23372f0ec5 100644 --- a/src/pkg/image/jpeg/writer.go +++ b/src/pkg/image/jpeg/writer.go @@ -302,14 +302,11 @@ func (e *encoder) writeMarkerHeader(marker uint8, markerlen int) { // writeDQT writes the Define Quantization Table marker. func (e *encoder) writeDQT() { - markerlen := 2 - for _, q := range e.quant { - markerlen += 1 + len(q) - } + markerlen := 2 + int(nQuantIndex)*(1+blockSize) e.writeMarkerHeader(dqtMarker, markerlen) - for i, q := range e.quant { + for i := range e.quant { e.writeByte(uint8(i)) - e.write(q[:]) + e.write(e.quant[i][:]) } }