From cdc230598e795cd53c5b976402901efe0de268e9 Mon Sep 17 00:00:00 2001 From: Fabian Giesen Date: Sat, 13 Dec 2014 18:07:00 -0800 Subject: [PATCH] stb_image: Fast path for matches with dist=1 (runs) in stbi__parse_huffman_block. --- stb_image.h | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/stb_image.h b/stb_image.h index ba9e065..318ea94 100644 --- a/stb_image.h +++ b/stb_image.h @@ -2210,8 +2210,12 @@ static int stbi__parse_huffman_block(stbi__zbuf *a) zout = a->zout; } p = (stbi_uc *) (zout - dist); - while (len--) - *zout++ = *p++; + if (dist == 1) { // run of one byte; common in images. + stbi_uc v = *p; + do *zout++ = v; while (--len); + } else { + do *zout++ = *p++; while (--len); + } } } }