Skip to content

Commit

Permalink
Efficient UnmodifiableMultimap forEach
Browse files Browse the repository at this point in the history
forEach can pass calls directly to the delegate protected
collection because it is a read-only operation.

Fixes #3911
Fixes #3912

RELNOTES=n/a

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=314952594
  • Loading branch information
carterkozak authored and kluever committed Jun 9, 2020
1 parent 2b5c096 commit 2d34685
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions guava/src/com/google/common/collect/Multimaps.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
import java.util.Set;
import java.util.SortedSet;
import java.util.Spliterator;
import java.util.function.BiConsumer;
import java.util.function.Consumer;
import java.util.stream.Collector;
import java.util.stream.Stream;
Expand Down Expand Up @@ -694,6 +695,11 @@ public Collection<Entry<K, V>> entries() {
return result;
}

@Override
public void forEach(BiConsumer<? super K, ? super V> consumer) {
delegate.forEach(checkNotNull(consumer));
}

@Override
public Collection<V> get(K key) {
return unmodifiableValueCollection(delegate.get(key));
Expand Down

0 comments on commit 2d34685

Please sign in to comment.