| OLD | NEW |
| 1 {% from 'macros.tmpl' import license %} | 1 {% from 'macros.tmpl' import license %} |
| 2 {% from 'macros.tmpl' import trie_length_switch %} |
| 3 {% macro trie_return_statement(tag) %} |
| 4 return {{tag}}Tag.localName().impl(); |
| 5 {% endmacro %} |
| 2 {{license()}} | 6 {{license()}} |
| 3 {% macro trie_switch(trie, index) %} | |
| 4 {# FIXME: No need to switch if there's only a single item in the subtrie: | |
| 5 can just have an if statement as we're currently doing for leaves. #} | |
| 6 switch (data[{{index}}]) { | |
| 7 {% for char, subtrie, tag, conditions in trie %} | |
| 8 case '{{char}}': | |
| 9 {% if subtrie %}{# Recurse on subtrie #} | |
| 10 {{trie_switch(subtrie, index + 1) | indent}} | |
| 11 {% elif conditions %}{# Check suffix #} | |
| 12 if ({{conditions | join(' && ')}}) | |
| 13 return {{tag}}Tag.localName().impl(); | |
| 14 return 0; | |
| 15 {% else %}{# Terminal node (no suffix) #} | |
| 16 return {{tag}}Tag.localName().impl(); | |
| 17 {% endif %} | |
| 18 {% endfor %} | |
| 19 } | |
| 20 return 0; | |
| 21 {% endmacro %} | |
| 22 | 7 |
| 23 #include "{{namespace}}ElementLookupTrie.h" | 8 #include "{{namespace}}ElementLookupTrie.h" |
| 24 | 9 |
| 25 #include "{{namespace}}Names.h" | 10 #include "{{namespace}}Names.h" |
| 26 | 11 |
| 27 namespace blink { | 12 namespace blink { |
| 28 | 13 |
| 29 using namespace {{namespace}}Names; | 14 using namespace {{namespace}}Names; |
| 30 | 15 |
| 31 StringImpl* lookup{{namespace}}Tag(const UChar* data, unsigned length) | 16 StringImpl* lookup{{namespace}}Tag(const UChar* data, unsigned length) |
| 32 { | 17 { |
| 33 ASSERT(data); | 18 DCHECK(data); |
| 34 ASSERT(length); | 19 DCHECK(length); |
| 35 switch (length) { | 20 {{trie_length_switch(empty_case_return_value, length_tries, trie_return_stat
ement, '0')}} |
| 36 {% for length, trie in length_tries %} | |
| 37 case {{length}}: | |
| 38 {{trie_switch(trie, 0) | indent(8)}} | |
| 39 {% endfor %} | |
| 40 } | |
| 41 return 0; | |
| 42 } | 21 } |
| 43 | 22 |
| 44 } // namespace blink | 23 } // namespace blink |
| OLD | NEW |