From: Christian Weisgerber Subject: Re: deltify addblk() fixes To: gameoftrees@openbsd.org Date: Fri, 11 Jun 2021 00:11:47 +0200 Stefan Sperling: > Thank you! Here is a new diff with these problems fixed. > > Your fixes don't make a huge difference but they do cause 'malloc' > and 'fseek' calls reported by gprof to drop down by about 2% on a > trivial test repository. ok naddy@ I have a further suggestion, though: while (dt->blocks[i].len != 0) { if (r == 0) { ... read block into buf ... } if (len == dt->blocks[i].len && h == dt->blocks[i].hash) { ... read other block into buf2 and compare ... } i = (i + 1) % dt->nalloc; } There's no point in reading a block until we know that we need to compare it. The "if (r == 0)" part should move under the following if. if (len == dt->blocks[i].len && h == dt->blocks[i].hash) { if (r == 0) { ... read block into buf ... } ... read other block into buf2 and compare ... } -- Christian "naddy" Weisgerber naddy@mips.inka.de