1 {% from 'macros.tmpl' import 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 %}
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();
15 {% else %}{# Terminal node (no suffix) #}
16 return {{tag}}Tag.localName().impl();
24 #include "{{namespace}}ElementLookupTrie.h"
26 #include "{{namespace}}Names.h"
30 using namespace {{namespace}}Names;
32 StringImpl* lookup{{namespace}}Tag(const UChar* data, unsigned length)
37 {% for length, trie in length_tries %}
39 {{trie_switch(trie, 0) | indent(8)}}