[Zlib-devel] inflate_table() performance - use of pointer (code *here)

Török Edwin edwin+ml-zlib at etorok.net
Mon Aug 27 08:14:03 EDT 2012


On 08/27/2012 03:05 PM, Petr Sumbera wrote:
> Hi,
> 
> one of my colleges came up with patch which gives about 8% improvement for decompression.
> 
> It basically does following in inflate_table():
> 
> -    code here;                  /* retrieved table entry */
> +    code *here;                 /* retrieved table entry */

Interesting, does it eliminate some redundant byte copies that the compiler didn't notice?

> 
> See attached full diff.
> 
> Any comments?

You can make it const since nothing writes to it: 'const code *here'.
And then you can avoid the casts to (code*), since they are const code* already:
            here = &(dcode[hold & dmask]);
            here = &(dcode[here->val + (hold & ((1U << op) - 1))]);
	    here = &(lcode[here->val + (hold & ((1U << op) - 1))]);

Best regards,
--Edwin




More information about the Zlib-devel mailing list