Paul Burba wrote:
> On Wed, Nov 28, 2012 at 2:25 PM, Julian Foad wrote:
>>> +/* Remove all prop name value pairs from PROP_HASH where the property
>>> +   name is not PROPNAME. */
>>> +static void
>>> +filter_unwanted_props(apr_hash_t *prop_hash,
>>> +                      const char * propname,
>>> +                      apr_pool_t *scratch_pool)
>>> +{
>>> +  apr_hash_index_t *hi;
>>> +
>>> +  for (hi = apr_hash_first(scratch_pool, prop_hash);
>>> +       hi;
>>> +       hi = apr_hash_next(hi))
>>> +    {
>>> +      const char *ipropname = svn__apr_hash_index_key(hi);
>>> +
>>> +      if (strcmp(ipropname, propname) != 0)
>>> +        apr_hash_set(prop_hash, ipropname, APR_HASH_KEY_STRING, NULL);
>>> +    }
>> 
>> I suppose a much quicker way to select just the wanted key-value pair from 
>> the hash is:
>> 
>>    propval = hash_get(propname)
>>    hash_clear()
> 
> (Julian - sorry for the tardy reply, I was cleaning out old TODOs
> today and found this)
> 
> apr_hash_clear clears the hash by iterating over it just like we do above:
[...]
> I did a quick test: Set 10,000 properties on the root of a WC then
> ran 'svn pg some-prop some-subtree-path --show-inherited-props'.
> Average execution time over 5 runs was .052s for the existing code and
> .056s for your suggested change

IIRC I was thinking how many seconds quicker I could read the code as well as 
how many nanoseconds quicker I assumed hash_clear would be at run time.  That 
using the latter adds a microsecond [1] surprises me -- and I'm sure 
apr_hash_clear could be optimized if you care about such things -- but either 
way you'll have to run "svn pg" an awful lot of times now for it to add up to 
the hour I've spent looking at this.

> ...so I'll leave the code as is.

OK.

- Julian


[1] Linear extrapolation, assuming << 10 props on a typical directory.

Reply via email to