Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3367)

Unified Diff: third_party/WebKit/Source/build/scripts/templates/ElementLookupTrie.cpp.tmpl

Issue 1978703002: Factor and simplify generation of the lookup trie used for HTMLLookupTrie. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove newlines Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..af90e6ab22314b8cc0ec38671a901347f1465dcb 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 %}
-{{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 %}
+{% from 'macros.tmpl' import trie_length_switch %}
+// Copyright (c) 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
#include "{{namespace}}ElementLookupTrie.h"
@@ -30,15 +13,11 @@ 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);
+ {% macro trie_return_statement(tag) %}{{tag}}Tag.localName().impl(){% endmacro %}
+ {{ trie_length_switch(length_tries, trie_return_statement, false) | indent(4) }}
+ return nullptr;
}
} // namespace blink
« no previous file with comments | « third_party/WebKit/Source/build/scripts/scripts.gypi ('k') | third_party/WebKit/Source/build/scripts/templates/macros.tmpl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698