On Sun, Dec 05, 2010 at 09:16:53AM -0000, pet...@apache.org wrote:
> Author: peters
> Date: Sun Dec  5 09:15:42 2010
> New Revision: 1042294
> 
> URL: http://svn.apache.org/viewvc?rev=1042294&view=rev
> Log:
> Optimize and simplify svn_checksum_parse_hex().  In my tests, the new
> version is 20% to 30% faster.  The EBCDIC port would probably need an
> #ifdef here.
> 
> Also happens to fix the case of input with uppercase A-F characters.
> We neither parsed them correctly nor rejected them as invalid.
> Now we accept _and_ parse them correctly.
> 
> * subversion/libsvn_subr/checksum.c
>   (svn_checksum_parse_hex): Rewrite to do a single table lookup to find
>    the validity and value of a hex byte, rather than two lookups
>    (svn_ctype_isxdigit, svn_ctype_isalpha) plus some ASCII math.
>    Also, don't bother to qualify char as unsigned except where actually
>    needed, and rename is_zeros to is_nonzero to match its meaning.
> 
> Modified:
>     subversion/trunk/subversion/libsvn_subr/checksum.c
 
> -      is_zeros |= (*checksum)->digest[i];
> +      is_nonzero |= ((char *)(*checksum)->digest)[i] = x1 << 4 | x2;

At the very least, this needs parenthesis unless you want everyone
to pull out their copy of K&R to check operator precedence rules.

Can we do one assignment per line instead? Maybe that's easier to parse.

Stefan

Reply via email to