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

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

Issue 1405573003: Introduce StringImpl::createPreallocatedStatic (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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/MakeNames.cpp.tmpl
diff --git a/third_party/WebKit/Source/build/scripts/templates/MakeNames.cpp.tmpl b/third_party/WebKit/Source/build/scripts/templates/MakeNames.cpp.tmpl
index ed0c03160f41f7ef42c01dc3f783c5c1a13ca419..a124c905336e8a21d8ca83cf903b233adc09491b 100644
--- a/third_party/WebKit/Source/build/scripts/templates/MakeNames.cpp.tmpl
+++ b/third_party/WebKit/Source/build/scripts/templates/MakeNames.cpp.tmpl
@@ -27,20 +27,22 @@ const AtomicString& {{entry|symbol}} = reinterpret_cast<AtomicString*>(&{{suffix
void init{{suffix}}()
{
+ const int kMaxNameLength = {{entries|map(attribute='name')|map('length')|max}} + 1;
struct NameEntry {
- const char* name;
+ char string_impl_storage[sizeof(StringImpl)];
tkent 2015/10/21 03:19:33 * Need a comment that the layout should be matched
Daniel Bratell 2015/10/21 09:51:25 This looks like it could make the Names array rath
tzik 2015/10/28 14:33:31 Done.
tzik 2015/10/28 14:33:31 |name| needs to be an array instead of char* to ma
+ char name[kMaxNameLength];
unsigned hash;
unsigned char length;
};
- static const NameEntry kNames[] = {
+ static NameEntry Names[] = {
tkent 2015/10/21 03:19:33 You don't need to rename kNames to Names, which do
tzik 2015/10/28 14:33:31 Done.
{% for entry in entries|sort(attribute='name', case_sensitive=True) %}
- { "{{entry|cpp_name}}", {{entry|cpp_name|hash}}, {{entry|cpp_name|length}} },
+ { "", "{{entry|cpp_name}}", {{entry|cpp_name|hash}}, {{entry|cpp_name|length}} },
{% endfor %}
};
- for (size_t i = 0; i < WTF_ARRAY_LENGTH(kNames); i++) {
- StringImpl* stringImpl = StringImpl::createStatic(kNames[i].name, kNames[i].length, kNames[i].hash);
+ for (size_t i = 0; i < WTF_ARRAY_LENGTH(Names); i++) {
+ StringImpl* stringImpl = StringImpl::createPreallocatedStatic(Names[i].string_impl_storage, Names[i].length, Names[i].hash);
void* address = reinterpret_cast<AtomicString*>(&{{suffix}}NamesStorage) + i;
new (address) AtomicString(stringImpl);
}

Powered by Google App Engine
This is Rietveld 408576698