Skip to content

Commit

Permalink
Store values in a local first instead of repeatedly reading it from…
Browse files Browse the repository at this point in the history
… 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
  • Loading branch information
cpovirk committed Mar 16, 2020
1 parent bfacdb0 commit 9ee6997
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ abstract class CollectionFuture<V, C> extends AggregateFuture<V, C> {
boolean allMustSucceed) {
super(futures, allMustSucceed, true);

this.values =
List<Present<V>> values =
futures.isEmpty()
? ImmutableList.<Present<V>>of()
: Lists.<Present<V>>newArrayListWithCapacity(futures.size());
Expand All @@ -50,6 +50,8 @@ abstract class CollectionFuture<V, C> extends AggregateFuture<V, C> {
for (int i = 0; i < futures.size(); ++i) {
values.add(null);
}

this.values = values;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ abstract class CollectionFuture<V, C> extends AggregateFuture<V, C> {
boolean allMustSucceed) {
super(futures, allMustSucceed, true);

this.values =
List<Present<V>> values =
futures.isEmpty()
? ImmutableList.<Present<V>>of()
: Lists.<Present<V>>newArrayListWithCapacity(futures.size());
Expand All @@ -50,6 +50,8 @@ abstract class CollectionFuture<V, C> extends AggregateFuture<V, C> {
for (int i = 0; i < futures.size(); ++i) {
values.add(null);
}

this.values = values;
}

@Override
Expand Down

0 comments on commit 9ee6997

Please sign in to comment.