Bug 22874 - Convert HTTPHeaderMap to use AtomicString as its key
Summary: Convert HTTPHeaderMap to use AtomicString as its key
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Page Loading (show other bugs)
Version: 528+ (Nightly build)
Hardware: Mac OS X 10.5
: P2 Normal
Assignee: Stephanie Lewis
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-12-15 19:40 PST by Stephanie Lewis
Modified: 2008-12-22 14:16 PST (History)
0 users

See Also:


Attachments
patch (13.08 KB, patch)
2008-12-15 19:44 PST, Stephanie Lewis
ggaren: review+
Details | Formatted Diff | Diff
patch (13.08 KB, patch)
2008-12-15 19:44 PST, Stephanie Lewis
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
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.