Chromium Code Reviews| Index: third_party/WebKit/Source/build/scripts/templates/ElementLookupTrie.cpp.tmpl |
| diff --git a/third_party/WebKit/Source/build/scripts/templates/ElementLookupTrie.cpp.tmpl b/third_party/WebKit/Source/build/scripts/templates/ElementLookupTrie.cpp.tmpl |
| index d2e2acb8c403421e200d6a8c849ebee23bde8fbe..d03d1406d36f9d10604b80e5202c29cc63724c75 100644 |
| --- a/third_party/WebKit/Source/build/scripts/templates/ElementLookupTrie.cpp.tmpl |
| +++ b/third_party/WebKit/Source/build/scripts/templates/ElementLookupTrie.cpp.tmpl |
| @@ -1,24 +1,7 @@ |
| {% from 'macros.tmpl' import license %} |
| +{% from 'macros.tmpl' import trie_length_switch %} |
| +{% macro trie_return_statement(tag) %}{{tag}}Tag.localName().impl(){% endmacro %} |
|
Timothy Loh
2016/05/12 07:03:14
can this line go immediately before the trie_lengt
meade_UTC10
2016/05/13 03:48:19
Done.
|
| {{license()}} |
| -{% macro trie_switch(trie, index) %} |
| -{# FIXME: No need to switch if there's only a single item in the subtrie: |
| - can just have an if statement as we're currently doing for leaves. #} |
| -switch (data[{{index}}]) { |
| -{% for char, subtrie, tag, conditions in trie %} |
| -case '{{char}}': |
| - {% if subtrie %}{# Recurse on subtrie #} |
| - {{trie_switch(subtrie, index + 1) | indent}} |
| - {% elif conditions %}{# Check suffix #} |
| - if ({{conditions | join(' && ')}}) |
| - return {{tag}}Tag.localName().impl(); |
| - return 0; |
| - {% else %}{# Terminal node (no suffix) #} |
| - return {{tag}}Tag.localName().impl(); |
| - {% endif %} |
| -{% endfor %} |
| -} |
| -return 0; |
| -{% endmacro %} |
| #include "{{namespace}}ElementLookupTrie.h" |
| @@ -30,15 +13,9 @@ using namespace {{namespace}}Names; |
| StringImpl* lookup{{namespace}}Tag(const UChar* data, unsigned length) |
| { |
| - ASSERT(data); |
| - ASSERT(length); |
| - switch (length) { |
| - {% for length, trie in length_tries %} |
| - case {{length}}: |
| - {{trie_switch(trie, 0) | indent(8)}} |
| - {% endfor %} |
| - } |
| - return 0; |
| + DCHECK(data); |
| + DCHECK(length); |
| + {{ trie_length_switch(none, length_tries, trie_return_statement, '0') | indent(4) }} |
|
Timothy Loh
2016/05/12 07:03:14
0 -> nullptr
meade_UTC10
2016/05/13 03:48:19
Done.
|
| } |
| } // namespace blink |