[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

Re: svn commit: r1296640 - use sizeof() instead of magic numbers

From: Julian Foad <julianfoad_at_btopenworld.com>
Date: Tue, 6 Mar 2012 11:48:28 +0000 (GMT)

stefan2_at_apache.org wrote:

> URL: http://svn.apache.org/viewvc?rev=1296640&view=rev
> Log:
> * subversion/libsvn_repos/rev_hunt.c
>   (svn_repos_get_committed_info): use sizeof() instead of magic numbers

> -  committed_date_s = apr_hash_get(revprops,
> -                                  SVN_PROP_REVISION_DATE,
> -                                  8);
> +  committed_date_s = apr_hash_get(revprops,
> +                                  SVN_PROP_REVISION_DATE,
> +                                  sizeof(SVN_PROP_REVISION_DATE)-1);

Consider using the special value "APR_HASH_KEY_STRING".  Last time I looked at the APR hash source code, it looked like the implementation was (as far as I could see by inspection) approximately just as fast with "APR_HASH_KEY_STRING" as with passing the specific length.  Using it has the benefit of simplicity for the developers, reducing the opportunity for mistakes such as the one fixed by r1242353 (which is merely an example of an unnoticed typo in repetitive code, nothing to do with hash keys).

- Julian
Received on 2012-03-06 12:49:04 CET

This is an archived mail posted to the Subversion Dev mailing list.