OLD | NEW |
1 # Copyright 2017 The Chromium Authors. All rights reserved. | 1 # Copyright 2017 The Chromium Authors. All rights reserved. |
2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
4 | 4 |
5 """Contains a set of Chrome-specific size queries.""" | 5 """Contains a set of Chrome-specific size queries.""" |
6 | 6 |
7 import logging | 7 import logging |
8 import models | 8 import models |
9 | 9 |
10 | 10 |
11 class _Grouper(object): | 11 class _Grouper(object): |
12 def __init__(self): | 12 def __init__(self): |
13 self.groups = [] | 13 self.groups = [] |
14 | 14 |
15 def Add(self, name, group): | 15 def Add(self, name, group): |
16 logging.debug('Computed %s', name) | 16 logging.debug('Computed %s', name) |
17 group.name = name | 17 sorted_group = group.Sorted() |
18 self.groups.append(group) | 18 sorted_group.SetName(name) |
| 19 self.groups.append(sorted_group) |
19 return group.Inverted() | 20 return group.Inverted() |
20 | 21 |
21 def Finalize(self, remaining): | 22 def Finalize(self, remaining): |
22 self.groups.sort(key=lambda s:(s.name.startswith('Other'), -s.pss)) | 23 self.groups.sort(key=lambda s:(s.name.startswith('Other'), -s.pss)) |
23 if remaining: | 24 if remaining: |
24 stars = remaining.Filter(lambda s: s.name.startswith('*')) | 25 stars = remaining.Filter(lambda s: s.name.startswith('*')) |
25 if stars: | 26 if stars: |
26 remaining = stars.Inverted() | 27 remaining = stars.Inverted() |
27 stars.name = '** Merged Symbols' | 28 stars = stars.Sorted() |
| 29 stars.SetName('** Merged Symbols') |
28 self.groups.append(stars) | 30 self.groups.append(stars) |
29 remaining.name = 'Other' | 31 remaining.SetName('Other') |
30 self.groups.append(remaining) | 32 self.groups.append(remaining) |
31 | 33 |
32 logging.debug('Finalized') | 34 logging.debug('Finalized') |
33 return models.SymbolGroup(self.groups, is_sorted=True) | 35 return models.SymbolGroup(self.groups, is_sorted=True) |
34 | 36 |
35 | 37 |
36 def _CategorizeByChromeComponent(symbols): | 38 def _CategorizeByChromeComponent(symbols): |
37 g = _Grouper() | 39 g = _Grouper() |
38 | 40 |
39 # Put things that filter out a lot of symbols at the beginning where possible | 41 # Put things that filter out a lot of symbols at the beginning where possible |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
136 """Categorizes symbols that come from generated source files.""" | 138 """Categorizes symbols that come from generated source files.""" |
137 return _CategorizeGenerated(self._SymbolsArg(symbols)) | 139 return _CategorizeGenerated(self._SymbolsArg(symbols)) |
138 | 140 |
139 def CategorizeByChromeComponent(self, symbols=None): | 141 def CategorizeByChromeComponent(self, symbols=None): |
140 """Groups symbols by component using predefined queries.""" | 142 """Groups symbols by component using predefined queries.""" |
141 return _CategorizeByChromeComponent(self._SymbolsArg(symbols)) | 143 return _CategorizeByChromeComponent(self._SymbolsArg(symbols)) |
142 | 144 |
143 def TemplatesByName(self, symbols=None, depth=0): | 145 def TemplatesByName(self, symbols=None, depth=0): |
144 """Lists C++ templates grouped by name.""" | 146 """Lists C++ templates grouped by name.""" |
145 symbols = self._SymbolsArg(symbols) | 147 symbols = self._SymbolsArg(symbols) |
| 148 # Call Sorted() twice so that subgroups will be sorted. |
146 # TODO(agrieve): Might be nice to recursively GroupedByName() on these. | 149 # TODO(agrieve): Might be nice to recursively GroupedByName() on these. |
147 return symbols.WhereIsTemplate().GroupedByName(depth).Sorted() | 150 return symbols.WhereIsTemplate().Sorted().GroupedByName(depth).Sorted() |
OLD | NEW |