From 7fb5ed00a2b2e01243660b7a894c4b667e8fbed3 Mon Sep 17 00:00:00 2001 From: Saxon Date: Tue, 7 Jan 2020 13:53:26 +1030 Subject: [PATCH] codec/mjpeg/jpeg.go: simplified copies --- codec/mjpeg/jpeg.go | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/codec/mjpeg/jpeg.go b/codec/mjpeg/jpeg.go index d5f7b270..85aef03c 100644 --- a/codec/mjpeg/jpeg.go +++ b/codec/mjpeg/jpeg.go @@ -336,9 +336,7 @@ func writeHeader(p []byte, _type, width, height, nbqTab int, dri uint16, qtable p[idx] = byte(i) idx++ - src := qtable[64*i : (64*i)+64] - copy(p[idx:], src) - idx += len(src) + copy(p[idx:], qtable[64*i:(64*i)+64]) } // Define huffman table. @@ -402,13 +400,8 @@ func writeHuffman(p []byte, class, id int, bits, values []byte) int { n += int(bits[i]) } - src := bits[1:17] - copy(p[idx:], src) - idx += len(src) - - src = values[0:n] - copy(p[idx:], src) - idx += len(src) + idx += copy(p[idx:], bits[1:17]) + idx += copy(p[idx:], values[0:n]) return idx }