Commit a642f81b authored by sashab's avatar sashab Committed by Commit bot

Sort fields in ComputedStyleBase in decreasing order of size

Sort fields in ComputedStyleBase in decreasing order of size. This is
a micro optimization that improves field alignment and minimizes wasted
memory space.

From Intel on 'Coding for Performance':
https://software.intel.com/en-us/articles/coding-for-performance-data-alignment-and-structures
"One can try to minimize this memory wastage by ordering the structure
elements such that the widest (largest) element comes first, followed by
the second widest, and so on."

Another good explanation article:
https://msdn.microsoft.com/en-us/library/ewwyfdbe.aspx

BUG=628043

Review-Url: https://codereview.chromium.org/2558733002
Cr-Commit-Position: refs/heads/master@{#437813}
parent a3533cd7
...@@ -138,6 +138,10 @@ class ComputedStyleBaseWriter(make_style_builder.StyleBuilderWriter): ...@@ -138,6 +138,10 @@ class ComputedStyleBaseWriter(make_style_builder.StyleBuilderWriter):
is_inherited_method_name=property_name_lower + 'IsInherited', is_inherited_method_name=property_name_lower + 'IsInherited',
)) ))
# Small optimization: order fields by size, from largest to smallest,
# to reduce wasted space from alignment.
self._fields.sort(key=lambda f: f.size, reverse=True)
@template_expander.use_jinja('ComputedStyleBase.h.tmpl') @template_expander.use_jinja('ComputedStyleBase.h.tmpl')
def generate_base_computed_style_h(self): def generate_base_computed_style_h(self):
return { return {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment