Skip to content

Commit 9ee6997

Browse files
committed
Store values in a local first instead of repeatedly reading it from a field.
At worst, this is a no-op. At best, it may perform better. RELNOTES=n/a ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=301180270
1 parent bfacdb0 commit 9ee6997

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

android/guava/src/com/google/common/util/concurrent/CollectionFuture.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ abstract class CollectionFuture<V, C> extends AggregateFuture<V, C> {
4141
boolean allMustSucceed) {
4242
super(futures, allMustSucceed, true);
4343

44-
this.values =
44+
List<Present<V>> values =
4545
futures.isEmpty()
4646
? ImmutableList.<Present<V>>of()
4747
: Lists.<Present<V>>newArrayListWithCapacity(futures.size());
@@ -50,6 +50,8 @@ abstract class CollectionFuture<V, C> extends AggregateFuture<V, C> {
5050
for (int i = 0; i < futures.size(); ++i) {
5151
values.add(null);
5252
}
53+
54+
this.values = values;
5355
}
5456

5557
@Override

guava/src/com/google/common/util/concurrent/CollectionFuture.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ abstract class CollectionFuture<V, C> extends AggregateFuture<V, C> {
4141
boolean allMustSucceed) {
4242
super(futures, allMustSucceed, true);
4343

44-
this.values =
44+
List<Present<V>> values =
4545
futures.isEmpty()
4646
? ImmutableList.<Present<V>>of()
4747
: Lists.<Present<V>>newArrayListWithCapacity(futures.size());
@@ -50,6 +50,8 @@ abstract class CollectionFuture<V, C> extends AggregateFuture<V, C> {
5050
for (int i = 0; i < futures.size(); ++i) {
5151
values.add(null);
5252
}
53+
54+
this.values = values;
5355
}
5456

5557
@Override

0 commit comments

Comments
 (0)