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

Unified Diff: tools/metrics/histograms/pretty_print.py

Issue 509923003: about_flags::ReportCustomFlags() should use signed 32-bit IDs. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Cleanup. Created 6 years, 3 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
« no previous file with comments | « tools/metrics/histograms/histograms.xml ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/metrics/histograms/pretty_print.py
diff --git a/tools/metrics/histograms/pretty_print.py b/tools/metrics/histograms/pretty_print.py
index 00e9ff5d386d1fa3c7e3f0e845f814cad04da233..a53a33445bb4324508d38eae28f431e3aad572a4 100755
--- a/tools/metrics/histograms/pretty_print.py
+++ b/tools/metrics/histograms/pretty_print.py
@@ -80,14 +80,27 @@ def TransformByAlphabetizing(node):
# Put subnodes in a list of node,key pairs to allow for custom sorting.
subtag, key_function = ALPHABETIZATION_RULES[node.tagName]
subnodes = []
- last_key = -1
+ sort_key = -1
+ unset_node_keys_indexes = []
Ilya Sherman 2014/09/02 22:29:48 nit: Perhaps something like "pending_node_indices"
Alexander Alekseev 2014/09/02 23:53:28 Done.
for c in node.childNodes:
if (c.nodeType == xml.dom.minidom.Node.ELEMENT_NODE and
c.tagName == subtag):
- last_key = key_function(c)
- # Subnodes that we don't want to rearrange use the last node's key,
- # so they stay in the same relative position.
- subnodes.append( (c, last_key) )
+ sort_key = key_function(c)
+ # Replace sort keys for delayed nodes.
+ for idx in unset_node_keys_indexes:
+ subnodes[idx][1] = sort_key
+ unset_node_keys_indexes = []
+ else:
+ # Subnodes that we don't want to rearrange use the next node's key,
+ # so they stay in the same relative position.
+ # Therefore we delay setting key before next node is found.
Ilya Sherman 2014/09/02 22:29:48 nit: "before next node is found" -> "until the nex
Alexander Alekseev 2014/09/02 23:53:28 Done.
+ unset_node_keys_indexes.append(len(subnodes))
+
+ subnodes.append( [c, sort_key] )
+
+ # Use last sort key for trailing unknown nodes.
+ for idx in unset_node_keys_indexes:
+ subnodes[idx][1] = sort_key
# Sort the subnode list.
subnodes.sort(key=lambda pair: pair[1])
« no previous file with comments | « tools/metrics/histograms/histograms.xml ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698