mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
revert: ContainerUtil.unmodifiableOrEmpty* methods optimized for 1-element collections
Creating a new singleton collection might break comparison policy of the original collection.
(original commit e66890a6d2)
GitOrigin-RevId: b4092dc49b60881385f31553ffd504e59e483e41
This commit is contained in:
committed by
intellij-monorepo-bot
parent
a117e7858e
commit
5b18e1cafe
@@ -260,9 +260,6 @@ public class ContainerUtil extends ContainerUtilRt {
|
||||
if (size == 0) {
|
||||
return emptyList();
|
||||
}
|
||||
if (size == 1) {
|
||||
return Collections.singletonList(original.iterator().next());
|
||||
}
|
||||
return Collections.unmodifiableCollection(original);
|
||||
}
|
||||
|
||||
@@ -273,9 +270,6 @@ public class ContainerUtil extends ContainerUtilRt {
|
||||
if (size == 0) {
|
||||
return emptyList();
|
||||
}
|
||||
if (size == 1) {
|
||||
return Collections.singletonList(original.iterator().next());
|
||||
}
|
||||
return Collections.unmodifiableList(original);
|
||||
}
|
||||
|
||||
@@ -286,9 +280,6 @@ public class ContainerUtil extends ContainerUtilRt {
|
||||
if (size == 0) {
|
||||
return Collections.emptySet();
|
||||
}
|
||||
if (size == 1) {
|
||||
return Collections.singleton(original.iterator().next());
|
||||
}
|
||||
return Collections.unmodifiableSet(original);
|
||||
}
|
||||
|
||||
@@ -299,13 +290,7 @@ public class ContainerUtil extends ContainerUtilRt {
|
||||
if (size == 0) {
|
||||
return Collections.emptyMap();
|
||||
}
|
||||
if (size == 1) {
|
||||
Map.Entry<? extends K, ? extends V> entry = original.entrySet().iterator().next();
|
||||
return Collections.singletonMap(entry.getKey(), entry.getValue());
|
||||
}
|
||||
else {
|
||||
return Collections.unmodifiableMap(original);
|
||||
}
|
||||
return Collections.unmodifiableMap(original);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
Reference in New Issue
Block a user