Bug 119875

Summary: localeToScriptCodeForFontSelection should use hash tables with larger default capacity
Product: WebKit Reporter: Pratik Solanki <psolanki>
Component: WebCore Misc.Assignee: Pratik Solanki <psolanki>
Status: RESOLVED FIXED    
Severity: Normal CC: andersca, ap, benjamin, darin, psolanki
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
Patch darin: review+

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>