Bug 22874

Summary: Convert HTTPHeaderMap to use AtomicString as its key
Product: WebKit Reporter: Stephanie Lewis <slewis>
Component: Page LoadingAssignee: Stephanie Lewis <slewis>
Status: RESOLVED FIXED    
Severity: Normal    
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: Mac   
OS: OS X 10.5   
Attachments:
Description Flags
patch
ggaren: review+
patch none

Description Stephanie Lewis 2008-12-15 19:40:45 PST
Convert HTTPHeaderMap to use AtomicString as its key.  Most keys are standard so it is a memory win to use Atomic Strings for the keys.   After two hours of the Stress Test and > 10,000 resources, only ~150 unique headers had been used.
Comment 1 Stephanie Lewis 2008-12-15 19:44:22 PST
Created attachment 26041 [details]
patch
Comment 2 Stephanie Lewis 2008-12-15 19:44:29 PST
Created attachment 26042 [details]
patch
Comment 3 Geoffrey Garen 2008-12-15 23:12:40 PST
Comment on attachment 26041 [details]
patch

> +        static bool equal(const AtomicString& a, const AtomicString& b)
> +        {
> +            return equal(a.impl(), b.impl());
> +        }

I think you could make this more efficient like so:

return a == b || equal(a.impl(), b.impl());

That way, comparing two atomic strings that are indeed equal will just be a pointer comparison, and you only have to do a character-by-character comparison if the two strings are not equal, or are equal using different cases.

r=me
Comment 4 Darin Adler 2008-12-16 08:58:57 PST
I don't understand.

Any two atomic strings that are equal will have the same impl pointer. That's what an atomic string *is*. It's never correct to compare the characters in two atomic strings; wasted work!
Comment 5 Sam Weinig 2008-12-16 09:14:45 PST
(In reply to comment #4)
> I don't understand.
> 
> Any two atomic strings that are equal will have the same impl pointer. That's
> what an atomic string *is*. It's never correct to compare the characters in two
> atomic strings; wasted work!
> 

I believe the intent is to do a case-insensitive comparison, which an AtomicString pointer compare will not do.
Comment 6 Darin Adler 2008-12-16 09:23:52 PST
(In reply to comment #5)
> I believe the intent is to do a case-insensitive comparison, which an
> AtomicString pointer compare will not do.

I see now. This is CaseFoldingHash::equal that we're talking about. Got it.
Comment 7 Stephanie Lewis 2008-12-22 14:16:50 PST
committed r39338 => http://trac.webkit.org/projects/webkit/changeset/39338.