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

Side by Side Diff: third_party/WebKit/Source/build/scripts/make_css_property_names.py

Issue 1844223002: Literal AtomicString construction can rely on strlen optimization. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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 unified diff | Download patch
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 2
3 import subprocess 3 import subprocess
4 import sys 4 import sys
5 5
6 import css_properties 6 import css_properties
7 import in_generator 7 import in_generator
8 import license 8 import license
9 9
10 10
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
132 int index = id - firstCSSProperty; 132 int index = id - firstCSSProperty;
133 return propertyNameStringsPool + propertyNameStringsOffsets[index]; 133 return propertyNameStringsPool + propertyNameStringsOffsets[index];
134 } 134 }
135 135
136 const AtomicString& getPropertyNameAtomicString(CSSPropertyID id) 136 const AtomicString& getPropertyNameAtomicString(CSSPropertyID id)
137 { 137 {
138 ASSERT(id >= firstCSSProperty && id <= lastUnresolvedCSSProperty); 138 ASSERT(id >= firstCSSProperty && id <= lastUnresolvedCSSProperty);
139 int index = id - firstCSSProperty; 139 int index = id - firstCSSProperty;
140 static AtomicString* propertyStrings = new AtomicString[lastUnresolvedCSSPro perty]; // Intentionally never destroyed. 140 static AtomicString* propertyStrings = new AtomicString[lastUnresolvedCSSPro perty]; // Intentionally never destroyed.
141 AtomicString& propertyString = propertyStrings[index]; 141 AtomicString& propertyString = propertyStrings[index];
142 if (propertyString.isNull()) { 142 if (propertyString.isNull())
143 const char* propertyName = propertyNameStringsPool + propertyNameStrings Offsets[index]; 143 propertyString = AtomicString(propertyNameStringsPool + propertyNameStri ngsOffsets[index]);
144 propertyString = AtomicString(propertyName, strlen(propertyName), Atomic String::ConstructFromLiteral);
145 }
146 return propertyString; 144 return propertyString;
147 } 145 }
148 146
149 String getPropertyNameString(CSSPropertyID id) 147 String getPropertyNameString(CSSPropertyID id)
150 { 148 {
151 // We share the StringImpl with the AtomicStrings. 149 // We share the StringImpl with the AtomicStrings.
152 return getPropertyNameAtomicString(id).getString(); 150 return getPropertyNameAtomicString(id).getString();
153 } 151 }
154 152
155 String getJSPropertyName(CSSPropertyID id) 153 String getJSPropertyName(CSSPropertyID id)
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
231 # FIXME: If we could depend on Python 2.7, we would use subprocess.check _output 229 # FIXME: If we could depend on Python 2.7, we would use subprocess.check _output
232 gperf_args = [self.gperf_path, '--key-positions=*', '-P', '-n'] 230 gperf_args = [self.gperf_path, '--key-positions=*', '-P', '-n']
233 gperf_args.extend(['-m', '50']) # Pick best of 50 attempts. 231 gperf_args.extend(['-m', '50']) # Pick best of 50 attempts.
234 gperf_args.append('-D') # Allow duplicate hashes -> More compact code. 232 gperf_args.append('-D') # Allow duplicate hashes -> More compact code.
235 gperf = subprocess.Popen(gperf_args, stdin=subprocess.PIPE, stdout=subpr ocess.PIPE, universal_newlines=True) 233 gperf = subprocess.Popen(gperf_args, stdin=subprocess.PIPE, stdout=subpr ocess.PIPE, universal_newlines=True)
236 return gperf.communicate(gperf_input)[0] 234 return gperf.communicate(gperf_input)[0]
237 235
238 236
239 if __name__ == "__main__": 237 if __name__ == "__main__":
240 in_generator.Maker(CSSPropertyNamesWriter).main(sys.argv) 238 in_generator.Maker(CSSPropertyNamesWriter).main(sys.argv)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698