Chromium Code Reviews| Index: Source/build/scripts/templates/ElementFactory.cpp.tmpl | 
| diff --git a/Source/build/scripts/templates/ElementFactory.cpp.tmpl b/Source/build/scripts/templates/ElementFactory.cpp.tmpl | 
| index 1eca356b5b8cecf14501064c6f9d6725ab44b4a8..56398570ec707adfc991b69f21f474d3f49a146e 100644 | 
| --- a/Source/build/scripts/templates/ElementFactory.cpp.tmpl | 
| +++ b/Source/build/scripts/templates/ElementFactory.cpp.tmpl | 
| @@ -58,18 +58,21 @@ static PassRefPtr<{{namespace}}Element> {{tag|symbol}}Constructor( | 
| } | 
| {%- endfor %} | 
| -static void addTag(const QualifiedName& tag, ConstructorFunction func) | 
| -{ | 
| - g_constructors->set(tag.localName(), func); | 
| -} | 
| - | 
| static void createFunctionMap() | 
| { | 
| ASSERT(!g_constructors); | 
| g_constructors = new FunctionMap; | 
| + struct CreateFunctionMapData { | 
| + const QualifiedName& tag; | 
| + ConstructorFunction func; | 
| + }; | 
| + const CreateFunctionMapData data[] = { | 
| 
 
adamk
2014/02/18 18:28:41
Not sure if it matters (since this is only called
 
Daniel Bratell
2014/02/19 13:41:05
It's a tricky question. For a compile time constan
 
 | 
| {%- for tag in tags|sort if not tag.noConstructor %} | 
| - addTag({{tag|symbol}}Tag, {{tag|symbol}}Constructor); | 
| + { {{tag|symbol}}Tag, {{tag|symbol}}Constructor }, | 
| {%- endfor %} | 
| + }; | 
| + for (size_t i = 0; i < sizeof(data) / sizeof(*data); i++) | 
| 
 
adamk
2014/02/18 18:28:41
Nit: you can use WTF_ARRAY_LENGTH() (from wtf/StdL
 
Daniel Bratell
2014/02/19 13:41:05
Thanks!
 
 | 
| + g_constructors->set(data[i].tag.localName(), data[i].func); | 
| } | 
| PassRefPtr<{{namespace}}Element> {{namespace}}ElementFactory::create{{namespace}}Element( |