From 5118c50547eb7a0ffaee974f1d36463085cd98e4 Mon Sep 17 00:00:00 2001 From: Sergei Ivanov Date: Wed, 29 Apr 2015 22:53:33 +0100 Subject: [PATCH] #34 Used LinkedHashSet everywhere for faster iteration with a consistent predictable order --- .../com/google/protobuf/maven/AbstractProtocMojo.java | 8 ++++---- src/main/java/com/google/protobuf/maven/Protoc.java | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/main/java/com/google/protobuf/maven/AbstractProtocMojo.java b/src/main/java/com/google/protobuf/maven/AbstractProtocMojo.java index 9caa9c71..c1db9471 100644 --- a/src/main/java/com/google/protobuf/maven/AbstractProtocMojo.java +++ b/src/main/java/com/google/protobuf/maven/AbstractProtocMojo.java @@ -37,6 +37,7 @@ import java.security.NoSuchAlgorithmException; import java.util.Collections; import java.util.Enumeration; +import java.util.LinkedHashSet; import java.util.List; import java.util.Set; import java.util.jar.JarEntry; @@ -45,7 +46,6 @@ import static com.google.common.base.Preconditions.checkArgument; import static com.google.common.base.Preconditions.checkNotNull; import static com.google.common.base.Preconditions.checkState; -import static com.google.common.collect.Sets.newHashSet; import static java.lang.Math.max; import static java.lang.String.format; import static java.util.Arrays.asList; @@ -769,7 +769,7 @@ protected void doAttachFiles() { * @return A set of all dependency artifacts. */ protected ImmutableSet getDependencyArtifactFiles() { - final Set dependencyArtifactFiles = newHashSet(); + final Set dependencyArtifactFiles = new LinkedHashSet(); for (final Artifact artifact : getDependencyArtifacts()) { dependencyArtifactFiles.add(artifact.getFile()); } @@ -799,7 +799,7 @@ protected ImmutableSet makeProtoPathFromJars( if (temporaryProtoFileDirectory.exists()) { cleanDirectory(temporaryProtoFileDirectory); } - final Set protoDirectories = newHashSet(); + final Set protoDirectories = new LinkedHashSet(); for (final File classpathElementFile : classpathElementFiles) { // for some reason under IAM, we receive poms as dependent files // I am excluding .xml rather than including .jar as there may be other extensions in use (sar, har, zip) @@ -851,7 +851,7 @@ protected ImmutableSet findProtoFilesInDirectory(final File directory) thr protected ImmutableSet findProtoFilesInDirectories(final Iterable directories) throws IOException { checkNotNull(directories); - final Set protoFiles = newHashSet(); + final Set protoFiles = new LinkedHashSet(); for (final File directory : directories) { protoFiles.addAll(findProtoFilesInDirectory(directory)); } diff --git a/src/main/java/com/google/protobuf/maven/Protoc.java b/src/main/java/com/google/protobuf/maven/Protoc.java index 610165cd..38013f48 100644 --- a/src/main/java/com/google/protobuf/maven/Protoc.java +++ b/src/main/java/com/google/protobuf/maven/Protoc.java @@ -10,6 +10,7 @@ import org.codehaus.plexus.util.cli.Commandline; import java.io.File; +import java.util.LinkedHashSet; import java.util.List; import java.util.Set; @@ -17,7 +18,6 @@ import static com.google.common.base.Preconditions.checkNotNull; import static com.google.common.base.Preconditions.checkState; import static com.google.common.collect.Lists.newLinkedList; -import static com.google.common.collect.Sets.newHashSet; /** * This class represents an invokable configuration of the {@code protoc} compiler. @@ -349,9 +349,9 @@ static final class Builder { */ Builder(final String executable) { this.executable = checkNotNull(executable, "executable"); - this.protoFiles = newHashSet(); - this.protopathElements = newHashSet(); - this.plugins = newHashSet(); + this.protoFiles = new LinkedHashSet(); + this.protopathElements = new LinkedHashSet(); + this.plugins = new LinkedHashSet(); } /**