diff --git a/s2/encode_better.go b/s2/encode_better.go index 6e15917340..f4c5e04d2f 100644 --- a/s2/encode_better.go +++ b/s2/encode_better.go @@ -63,6 +63,9 @@ func encodeBlockBetter(dst, src []byte) (d int) { // lets us use a fast path for emitLiteral in the main loop, while we are // looking for copies. sLimit := len(src) - inputMargin + if len(src) < minNonLiteralBlockSize { + return 0 + } // Bail if we can't compress to at least this. dstLimit := len(src) - len(src)>>5 - 5