diff options
author | Han-Wen Nienhuys <hanwen@google.com> | 2015-11-17 19:30:08 +0000 |
---|---|---|
committer | Lukacs Berki <lberki@google.com> | 2015-11-18 15:30:13 +0000 |
commit | d783596d18373ab658c85cdcf7afb5cb8c063c8e (patch) | |
tree | 3a091e8f248507b92f5463640ebdfa0840dc5688 /src/main | |
parent | e6180d389896c9f91d4afcb2c1672efd308f9fcf (diff) |
Sort entries in SelectorValue.
This makes query output independent of the insertion order of the dictionary.
--
MOS_MIGRATED_REVID=108061190
Diffstat (limited to 'src/main')
-rw-r--r-- | src/main/java/com/google/devtools/build/lib/syntax/SelectorValue.java | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/syntax/SelectorValue.java b/src/main/java/com/google/devtools/build/lib/syntax/SelectorValue.java index 28aa22f222..8d253b32e9 100644 --- a/src/main/java/com/google/devtools/build/lib/syntax/SelectorValue.java +++ b/src/main/java/com/google/devtools/build/lib/syntax/SelectorValue.java @@ -16,6 +16,7 @@ package com.google.devtools.build.lib.syntax; import com.google.common.collect.Iterables; import java.util.Map; +import java.util.TreeMap; /** * The value passed to a select({...}) statement, e.g.: @@ -30,14 +31,15 @@ import java.util.Map; * </pre> */ public final class SelectorValue { - // TODO(build-team): Selectors are currently split between .packages and .syntax . They should + // TODO(bazel-team): Selectors are currently split between .packages and .syntax . They should // really all be in .packages, but then we'd need to figure out a way how to extend binary // operators, which is a non-trivial problem. private final Map<?, ?> dictionary; private final Class<?> type; public SelectorValue(Map<?, ?> dictionary) { - this.dictionary = dictionary; + // Put the dict through a sorting to avoid depending on insertion order. + this.dictionary = new TreeMap<>(dictionary); this.type = dictionary.isEmpty() ? null : Iterables.get(dictionary.values(), 0).getClass(); } |