Bug 119875 - localeToScriptCodeForFontSelection should use hash tables with larger default capacity
Summary: localeToScriptCodeForFontSelection should use hash tables with larger default...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebCore Misc. (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Pratik Solanki
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-08-15 17:45 PDT by Pratik Solanki
Modified: 2013-08-20 11:49 PDT (History)
5 users (show)

See Also:


Attachments
Patch (26.89 KB, patch)
2013-08-15 17:56 PDT, Pratik Solanki
darin: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Pratik Solanki 2013-08-15 17:45:03 PDT
LocaleToScriptMappingDefault.cpp has 2 static hash maps with a large number of values (108 and 196). We should initialize these to a larger capacity so we don't start from 8 and churn through their growth.
Comment 1 Pratik Solanki 2013-08-15 17:56:06 PDT
Created attachment 208873 [details]
Patch
Comment 2 Darin Adler 2013-08-15 18:24:52 PDT
Comment on attachment 208873 [details]
Patch

Tweaking the size of these hash tables is OK. But a way better thing to do would be to not use a hash table for this. There is suitable code in the quotesForLanguage function in RenderQuote.cpp that we could generalize, put in WTF, and use here.
Comment 3 Pratik Solanki 2013-08-19 16:48:01 PDT
That sounds interesting. I can look into refactoring this. Should this patch be abandoned or should we check this in for now while we investigate a better approach?
Comment 4 Darin Adler 2013-08-20 09:15:02 PDT
I don’t feel strongly either way; fine to land this. But way better to not dynamically created hash tables for this long term. Generally speaking we want to build tables at compile time. I must admit I’m not sure why we chose to use gperf for some things like this, but not for others. Maybe we should be using gperf more consistently?
Comment 5 Darin Adler 2013-08-20 09:15:46 PDT
Comment on attachment 208873 [details]
Patch

OK to land for now, but we should do better, as I mentioned.
Comment 6 Pratik Solanki 2013-08-20 10:50:00 PDT
Thanks for the review. I'll look into factoring out the code from RenderQuote.
Comment 7 Pratik Solanki 2013-08-20 11:49:48 PDT
Committed r154347: <http://trac.webkit.org/changeset/154347>