summaryrefslogtreecommitdiffstats
path: root/chromium/third_party/WebKit/Source/build/scripts/templates/ElementLookupTrie.cpp.tmpl
diff options
context:
space:
mode:
Diffstat (limited to 'chromium/third_party/WebKit/Source/build/scripts/templates/ElementLookupTrie.cpp.tmpl')
-rw-r--r--chromium/third_party/WebKit/Source/build/scripts/templates/ElementLookupTrie.cpp.tmpl28
1 files changed, 25 insertions, 3 deletions
diff --git a/chromium/third_party/WebKit/Source/build/scripts/templates/ElementLookupTrie.cpp.tmpl b/chromium/third_party/WebKit/Source/build/scripts/templates/ElementLookupTrie.cpp.tmpl
index 36caa9cbcb9..fc237d6c559 100644
--- a/chromium/third_party/WebKit/Source/build/scripts/templates/ElementLookupTrie.cpp.tmpl
+++ b/chromium/third_party/WebKit/Source/build/scripts/templates/ElementLookupTrie.cpp.tmpl
@@ -1,5 +1,24 @@
-{% from "macros.tmpl" import license -%}
-{{ license() }}
+{% from 'macros.tmpl' import license %}
+{{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 "config.h"
#include "{{namespace}}ElementLookupTrie.h"
@@ -15,7 +34,10 @@ StringImpl* lookup{{namespace}}Tag(const UChar* data, unsigned length)
ASSERT(data);
ASSERT(length);
switch (length) {
-{{body}}
+ {% for length, trie in length_tries %}
+ case {{length}}:
+ {{trie_switch(trie, 0) | indent(8)}}
+ {% endfor %}
}
return 0;
}