Create context map lazily
@@ -186,15 +186,17 @@ public class DimensionBinding {
* or null if they are incompatible.
*/
private Map<String, String> combineValues(Map<String, String> m1, Map<String, String> m2) {
- Map<String, String> combinedValues = new LinkedHashMap<>(m1);
+ Map<String, String> combinedValues = null;
for (Map.Entry<String, String> m2Entry : m2.entrySet()) {
if (m2Entry.getValue() == null) continue;
String m1Value = m1.get(m2Entry.getKey());
if (m1Value != null && ! m1Value.equals(m2Entry.getValue()))
return null; // conflicting values of a key
+ if (combinedValues == null)
+ combinedValues = new LinkedHashMap<>(m1);
combinedValues.put(m2Entry.getKey(), m2Entry.getValue());
}
- return combinedValues;
+ return combinedValues == null ? m1 : combinedValues;
}
private boolean intersects(List<String> l1, List<String> l2) {
