On Fri, Nov 03, 2006 at 04:30:30PM -0500, Jeff Moyer wrote:
> 
> This patch is again from Chris Feist.  Comments welcome.
> 
> +                     if (strlen(mkey) == key_len &&
> +                         strncmp(mkey, key, key_len) == 0) {

If this was a Google interview, I'd say that doing the strncmp before
the strlen is more efficient. With equal keys it does not matter, but
with different keys strncmp will bail out in the middle of the key, on
average, and strlen will always scan the whole key. So doing strlen
and then strncmp scans 1.5 the length of the key on average, while
doing strncmp and then strlen scans 0.5 of it (with different keys,
remember).

Other than that, the patch seems to be the right thing to do. :)

Fábio
-- 
ex sed lex awk yacc, e pluribus unix, amem

_______________________________________________
autofs mailing list
[email protected]
http://linux.kernel.org/mailman/listinfo/autofs

Reply via email to