Loading... (original) (raw)
The test java/util/Map/Collisions.java contains the following code:
for (int i = 0; i < keys.length; i++) {
check(String.format("insertion: map expected size m%d != i%d", map.size(), i), map.size() == i);
check(String.format("insertion: put(%s[%d])", keys_desc, i), null == map.put(keys[i], keys[i]));
check(String.format("insertion: containsKey(%s[%d])", keys_desc, i), map.containsKey(keys[i]));
check(String.format("insertion: containsValue(%s[%d])", keys_desc, i), map.containsValue(keys[i]));
}
and many similar cases. These are expensive, as they format a string that is in most cases thrown away. The check() method should be rewritten to use lazy message formatting.