From 161f02171c05a37751c7ca314daf5e5b4809905f Mon Sep 17 00:00:00 2001 From: Klaus Post Date: Fri, 10 Jun 2022 13:07:14 +0200 Subject: [PATCH] [klauspost/inflate-improve-speed] Fix up comments Change-Id: If11b81d2de23a2588f3d4c7baa088ed5d614de70 --- src/compress/flate/gen_inflate.go | 6 ++---- src/compress/flate/inflate_gen.go | 30 ++++++++++-------------------- 2 files changed, 12 insertions(+), 24 deletions(-) diff --git a/src/compress/flate/gen_inflate.go b/src/compress/flate/gen_inflate.go index a0d1b318bc1..d5c9a0b94e7 100644 --- a/src/compress/flate/gen_inflate.go +++ b/src/compress/flate/gen_inflate.go @@ -56,7 +56,7 @@ func (f *decompressor) $FUNCNAME$() { // Optimization. Compiler isn't smart enough to keep f.b, f.nb in registers, // but is smart enough to keep local variables in registers, so use nb and b, - // inline call to moreBits and reassign b, nb back to f on return. + // dict reference and reassign b, nb back to f on return. fnb, fb, dict := f.nb, f.b, &f.dict switch f.stepState { case stateInit: @@ -125,6 +125,7 @@ readLiteral: return // otherwise, reference to older data case v < 265: + // No extra bits length = v - (257 - 3) case v < maxNumLit: val := decCodeToLen[(v - 257)] @@ -171,9 +172,6 @@ readLiteral: // cases, the chunks slice will be 0 for the invalid sequence, leading it // satisfy the n == 0 check below. n := uint(f.hd.maxRead) - // Optimization. Compiler isn't smart enough to keep f.b,f.nb in registers, - // but is smart enough to keep local variables in registers, so use nb and b, - // inline call to moreBits and reassign b,nb back to f on return. for { for fnb < n { c, err := fr.ReadByte() diff --git a/src/compress/flate/inflate_gen.go b/src/compress/flate/inflate_gen.go index 3740f812408..1ab2fa7c457 100644 --- a/src/compress/flate/inflate_gen.go +++ b/src/compress/flate/inflate_gen.go @@ -23,7 +23,7 @@ func (f *decompressor) huffmanBytesBuffer() { // Optimization. Compiler isn't smart enough to keep f.b, f.nb in registers, // but is smart enough to keep local variables in registers, so use nb and b, - // inline call to moreBits and reassign b, nb back to f on return. + // dict reference and reassign b, nb back to f on return. fnb, fb, dict := f.nb, f.b, &f.dict switch f.stepState { case stateInit: @@ -92,6 +92,7 @@ readLiteral: return // otherwise, reference to older data case v < 265: + // No extra bits length = v - (257 - 3) case v < maxNumLit: val := decCodeToLen[(v - 257)] @@ -138,9 +139,6 @@ readLiteral: // cases, the chunks slice will be 0 for the invalid sequence, leading it // satisfy the n == 0 check below. n := uint(f.hd.maxRead) - // Optimization. Compiler isn't smart enough to keep f.b,f.nb in registers, - // but is smart enough to keep local variables in registers, so use nb and b, - // inline call to moreBits and reassign b,nb back to f on return. for { for fnb < n { c, err := fr.ReadByte() @@ -242,7 +240,7 @@ func (f *decompressor) huffmanBytesReader() { // Optimization. Compiler isn't smart enough to keep f.b, f.nb in registers, // but is smart enough to keep local variables in registers, so use nb and b, - // inline call to moreBits and reassign b, nb back to f on return. + // dict reference and reassign b, nb back to f on return. fnb, fb, dict := f.nb, f.b, &f.dict switch f.stepState { case stateInit: @@ -311,6 +309,7 @@ readLiteral: return // otherwise, reference to older data case v < 265: + // No extra bits length = v - (257 - 3) case v < maxNumLit: val := decCodeToLen[(v - 257)] @@ -357,9 +356,6 @@ readLiteral: // cases, the chunks slice will be 0 for the invalid sequence, leading it // satisfy the n == 0 check below. n := uint(f.hd.maxRead) - // Optimization. Compiler isn't smart enough to keep f.b,f.nb in registers, - // but is smart enough to keep local variables in registers, so use nb and b, - // inline call to moreBits and reassign b,nb back to f on return. for { for fnb < n { c, err := fr.ReadByte() @@ -461,7 +457,7 @@ func (f *decompressor) huffmanBufioReader() { // Optimization. Compiler isn't smart enough to keep f.b, f.nb in registers, // but is smart enough to keep local variables in registers, so use nb and b, - // inline call to moreBits and reassign b, nb back to f on return. + // dict reference and reassign b, nb back to f on return. fnb, fb, dict := f.nb, f.b, &f.dict switch f.stepState { case stateInit: @@ -530,6 +526,7 @@ readLiteral: return // otherwise, reference to older data case v < 265: + // No extra bits length = v - (257 - 3) case v < maxNumLit: val := decCodeToLen[(v - 257)] @@ -576,9 +573,6 @@ readLiteral: // cases, the chunks slice will be 0 for the invalid sequence, leading it // satisfy the n == 0 check below. n := uint(f.hd.maxRead) - // Optimization. Compiler isn't smart enough to keep f.b,f.nb in registers, - // but is smart enough to keep local variables in registers, so use nb and b, - // inline call to moreBits and reassign b,nb back to f on return. for { for fnb < n { c, err := fr.ReadByte() @@ -680,7 +674,7 @@ func (f *decompressor) huffmanStringsReader() { // Optimization. Compiler isn't smart enough to keep f.b, f.nb in registers, // but is smart enough to keep local variables in registers, so use nb and b, - // inline call to moreBits and reassign b, nb back to f on return. + // dict reference and reassign b, nb back to f on return. fnb, fb, dict := f.nb, f.b, &f.dict switch f.stepState { case stateInit: @@ -749,6 +743,7 @@ readLiteral: return // otherwise, reference to older data case v < 265: + // No extra bits length = v - (257 - 3) case v < maxNumLit: val := decCodeToLen[(v - 257)] @@ -795,9 +790,6 @@ readLiteral: // cases, the chunks slice will be 0 for the invalid sequence, leading it // satisfy the n == 0 check below. n := uint(f.hd.maxRead) - // Optimization. Compiler isn't smart enough to keep f.b,f.nb in registers, - // but is smart enough to keep local variables in registers, so use nb and b, - // inline call to moreBits and reassign b,nb back to f on return. for { for fnb < n { c, err := fr.ReadByte() @@ -899,7 +891,7 @@ func (f *decompressor) huffmanGenericReader() { // Optimization. Compiler isn't smart enough to keep f.b, f.nb in registers, // but is smart enough to keep local variables in registers, so use nb and b, - // inline call to moreBits and reassign b, nb back to f on return. + // dict reference and reassign b, nb back to f on return. fnb, fb, dict := f.nb, f.b, &f.dict switch f.stepState { case stateInit: @@ -968,6 +960,7 @@ readLiteral: return // otherwise, reference to older data case v < 265: + // No extra bits length = v - (257 - 3) case v < maxNumLit: val := decCodeToLen[(v - 257)] @@ -1014,9 +1007,6 @@ readLiteral: // cases, the chunks slice will be 0 for the invalid sequence, leading it // satisfy the n == 0 check below. n := uint(f.hd.maxRead) - // Optimization. Compiler isn't smart enough to keep f.b,f.nb in registers, - // but is smart enough to keep local variables in registers, so use nb and b, - // inline call to moreBits and reassign b,nb back to f on return. for { for fnb < n { c, err := fr.ReadByte()