Skip to content

Commit

Permalink
Consider avoiding the use of a pre-sized builder for the `FilteredCol…
Browse files Browse the repository at this point in the history
…lection` and `FilteredMultimapValues` in `Maps#uniqueIndex`
  • Loading branch information
oksana-evs committed Jul 14, 2023
1 parent cd0069a commit 51ec4e9
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion guava/src/com/google/common/collect/Maps.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
import com.google.common.base.Preconditions;
import com.google.common.base.Predicate;
import com.google.common.base.Predicates;
import com.google.common.collect.Collections2.FilteredCollection;
import com.google.common.collect.MapDifference.ValueDifference;
import com.google.common.primitives.Ints;
import com.google.errorprone.annotations.CanIgnoreReturnValue;
Expand Down Expand Up @@ -1325,7 +1326,8 @@ public static <K, V> ImmutableMap<K, V> toMap(
@CanIgnoreReturnValue
public static <K, V> ImmutableMap<K, V> uniqueIndex(
Iterable<V> values, Function<? super V, K> keyFunction) {
if (values instanceof Collection) {
if (values instanceof Collection
&& !(values instanceof FilteredCollection || values instanceof FilteredMultimapValues)) {
return uniqueIndex(
values.iterator(),
keyFunction,
Expand Down

0 comments on commit 51ec4e9

Please sign in to comment.