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

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

Issue 1405573003: Introduce StringImpl::createPreallocatedStatic (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: +comment. Removed StringImpl::createStatic. Created 5 years, 2 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/MakeQualifiedNames.cpp.tmpl
diff --git a/third_party/WebKit/Source/build/scripts/templates/MakeQualifiedNames.cpp.tmpl b/third_party/WebKit/Source/build/scripts/templates/MakeQualifiedNames.cpp.tmpl
index 3e32ccde735dcad12ba3ae1893d807df39c066b1..e38706409a910f2cc687c90c60da0f4040cecdc8 100644
--- a/third_party/WebKit/Source/build/scripts/templates/MakeQualifiedNames.cpp.tmpl
+++ b/third_party/WebKit/Source/build/scripts/templates/MakeQualifiedNames.cpp.tmpl
@@ -54,14 +54,6 @@ PassOwnPtr<const QualifiedName*[]> get{{namespace}}Attrs()
void init()
{
- struct NameEntry {
- const char* name;
- unsigned hash;
- unsigned char length;
- unsigned char isTag;
- unsigned char isAttr;
- };
-
// Use placement new to initialize the globals.
AtomicString {{namespace_prefix}}NS("{{namespace_uri}}", AtomicString::ConstructFromLiteral);
@@ -69,9 +61,21 @@ void init()
new ((void*)&{{namespace_prefix}}NamespaceURI) AtomicString({{namespace_prefix}}NS);
{% set tagnames = tags|map(attribute='name')|list() %}
{% set attrnames = attrs|map(attribute='name')|list() %}
- static const NameEntry kNames[] = {
+ const int kMaxNameLength = {{(tagnames + attrnames)|map('length')|max}} + 1;
+ struct NameEntry {
+ // StringImpl instances are created at |stringImplStorage| in-place.
+ // |name| must be placed soon after |stringImplStorage| to match the memory layout requirement of StringImpl.
+ char stringImplStorage[sizeof(StringImpl)];
+ char name[kMaxNameLength];
+ unsigned hash;
+ unsigned char length;
+ unsigned char isTag;
+ unsigned char isAttr;
+ };
+
+ static NameEntry kNames[] = {
{% for name, tag_list in (tags + attrs)|groupby('name')|sort(attribute=0, case_sensitive=True) %}
- { "{{name}}", {{name|hash}}, {{name|length}}, {{ (name in tagnames)|int }}, {{ (name in attrnames)|int }} },
+ { "", "{{name}}", {{name|hash}}, {{name|length}}, {{ (name in tagnames)|int }}, {{ (name in attrnames)|int }} },
{% endfor %}
};
@@ -80,7 +84,7 @@ void init()
{% endif %}
size_t attr_i = 0;
for (size_t i = 0; i < WTF_ARRAY_LENGTH(kNames); i++) {
- StringImpl* stringImpl = StringImpl::createStatic(kNames[i].name, kNames[i].length, kNames[i].hash);
+ StringImpl* stringImpl = StringImpl::createPreallocatedStatic(kNames[i].stringImplStorage, kNames[i].length, kNames[i].hash);
{% if tags %}
if (kNames[i].isTag) {
void* address = reinterpret_cast<{{namespace}}QualifiedName*>(&{{suffix}}TagStorage) + tag_i;
« no previous file with comments | « third_party/WebKit/Source/build/scripts/templates/MakeNames.cpp.tmpl ('k') | third_party/WebKit/Source/wtf/text/StringImpl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698