On Tue, Jan 8, 2013 at 10:57 PM, Kurchi Subhra Hazra
<kurchi.subhra.ha...@oracle.com> wrote:
> On 1/8/13 6:39 PM, David Schlosnagle wrote:
>>
>> Hi Kurchi,
>>
>> I had a couple quick comments:
>>
>> On line 1756, you might want to allocate the StringBuilder normalizedS
>> = new StringBuilder(s.length()); to avoid resizing during the
>> appending.
>
> - I am now wondering if I should directly calculate the hashCode instead of
> using a StringBuilder.

Seems reasonable to avoid copying the string.

>> On line 1754 and 1759, is it worth restructuring the logic to avoid
>> performing indexOf twice to find the first '%'? This might be
>> premature optimization as hopefully the URIs are short and that
>> indexOf would be replaced with an intrinsic if hot enough.
>
> It is possible to store the value of first occurrence of '%' in a variable,
> but I was
> trying to keep the case with no '%' clutter-free.

As Vitaly mentioned, it might be worthwhile to extract the '%' case to
a separate method, and if you're going to computer hashCode as you go
this is probably a non-issue.

- Dave

Reply via email to