You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@subversion.apache.org by Greg Stein <gs...@lyra.org> on 2002/06/07 19:24:51 UTC

Re: svn commit: rev 2112 - trunk/subversion/libsvn_repos

On Fri, Jun 07, 2002 at 12:03:35PM -0500, sussman@tigris.org wrote:
>...
> +++ trunk/subversion/libsvn_repos/load.c	Fri Jun  7 12:03:33 2002
>...
> +      /* Store name/value in hash. */
>        apr_hash_set (*headers, name, APR_HASH_KEY_STRING, value);

[optimization nit only]

The length of the name == i - 2

Cheers,
-g

-- 
Greg Stein, http://www.lyra.org/

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org

Re: svn commit: rev 2112 - trunk/subversion/libsvn_repos

Posted by Greg Stein <gs...@lyra.org>.
On Fri, Jun 07, 2002 at 03:04:34PM -0500, Karl Fogel wrote:
> Ben Collins-Sussman <su...@collab.net> writes:
> > Just a sanity check here, correct me if I'm wrong.  The rule we're
> > following is, "if you know the length, use it.  otherwise, use
> > APR_HASH_KEY_STRING."

Yes, that is the rule.

Note that it is possible to use binary values for hash keys, but we don't do
that. Of course, in that case, you will always be supplying a length.

> > Is that right?  I mean, the constant is just
> > running strlen, right?
> 
> Not quite.  The reason to prefer the constant is that it tells the
> hash function "This is a null-terminated string, so compute the key
> length *while* you compute its hash value."  So it only runs over the
> bytes once, instead of twice.

Exactly.

You can see the code in: apr/tables/apr_hash.c::find_entry(). (line 263)

Cheers,
-g

-- 
Greg Stein, http://www.lyra.org/

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org

Re: svn commit: rev 2112 - trunk/subversion/libsvn_repos

Posted by Karl Fogel <kf...@newton.ch.collab.net>.
Ben Collins-Sussman <su...@collab.net> writes:
> Just a sanity check here, correct me if I'm wrong.  The rule we're
> following is, "if you know the length, use it.  otherwise, use
> APR_HASH_KEY_STRING."  Is that right?  I mean, the constant is just
> running strlen, right?

Not quite.  The reason to prefer the constant is that it tells the
hash function "This is a null-terminated string, so compute the key
length *while* you compute its hash value."  So it only runs over the
bytes once, instead of twice.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org

Re: svn commit: rev 2112 - trunk/subversion/libsvn_repos

Posted by Ben Collins-Sussman <su...@collab.net>.
Greg Stein <gs...@lyra.org> writes:

> On Fri, Jun 07, 2002 at 12:03:35PM -0500, sussman@tigris.org wrote:
> >...
> > +++ trunk/subversion/libsvn_repos/load.c	Fri Jun  7 12:03:33 2002
> >...
> > +      /* Store name/value in hash. */
> >        apr_hash_set (*headers, name, APR_HASH_KEY_STRING, value);
> 
> [optimization nit only]
> 
> The length of the name == i - 2

Just a sanity check here, correct me if I'm wrong.  The rule we're
following is, "if you know the length, use it.  otherwise, use
APR_HASH_KEY_STRING."  Is that right?  I mean, the constant is just
running strlen, right?

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org