Skip to content

Commit

Permalink
Merge pull request #1061 from rubenporras/builderWithExpectedSize
Browse files Browse the repository at this point in the history
perf: use builderWithExpectedSize if possible
  • Loading branch information
rubenporras authored Jan 6, 2025
2 parents 02186dc + 8ad9409 commit 75a8a89
Showing 1 changed file with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,14 @@ public class FingerprintResourceDescription extends AbstractResourceDescription

public FingerprintResourceDescription(final IResourceDescription original) {
this.uri = original.getURI();
ImmutableList.Builder<IEObjectDescription> builder = ImmutableList.builder();
for (IEObjectDescription description : original.getExportedObjects()) {
Iterable<IEObjectDescription> objects = original.getExportedObjects();
ImmutableList.Builder<IEObjectDescription> builder;
if (objects instanceof List list) {
builder = ImmutableList.builderWithExpectedSize(list.size());
} else {
builder = ImmutableList.builder();
}
for (IEObjectDescription description : objects) {
builder.add(createLightDescription(description));
}
this.exportedObjects = builder.build();
Expand Down

0 comments on commit 75a8a89

Please sign in to comment.