Minor, don't intersect sets, use retainAll instead

This commit is contained in:
Alexander Udalov
2014-05-05 18:58:32 +04:00
parent eb11a7dc88
commit beb66e2247
@@ -555,12 +555,12 @@ public class TypeUtils {
private static Set<JetType> getIntersectionOfSupertypes(@NotNull Collection<JetType> types) { private static Set<JetType> getIntersectionOfSupertypes(@NotNull Collection<JetType> types) {
Set<JetType> upperBounds = Sets.newHashSet(); Set<JetType> upperBounds = Sets.newHashSet();
for (JetType type : types) { for (JetType type : types) {
Set<JetType> supertypes = Sets.newHashSet(type.getConstructor().getSupertypes()); Collection<JetType> supertypes = type.getConstructor().getSupertypes();
if (upperBounds.isEmpty()) { if (upperBounds.isEmpty()) {
upperBounds.addAll(supertypes); upperBounds.addAll(supertypes);
} }
else { else {
upperBounds = Sets.intersection(upperBounds, supertypes); upperBounds.retainAll(supertypes);
} }
} }
return upperBounds; return upperBounds;