Skip to content
This repository has been archived by the owner on Feb 12, 2018. It is now read-only.

Commit

Permalink
#34 Used LinkedHashSet everywhere for faster iteration with a consist…
Browse files Browse the repository at this point in the history
…ent predictable order
  • Loading branch information
sergei-ivanov committed Apr 29, 2015
1 parent 2bda15b commit 5118c50
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -769,7 +769,7 @@ protected void doAttachFiles() {
* @return A set of all dependency artifacts.
*/
protected ImmutableSet<File> getDependencyArtifactFiles() {
final Set<File> dependencyArtifactFiles = newHashSet();
final Set<File> dependencyArtifactFiles = new LinkedHashSet<File>();
for (final Artifact artifact : getDependencyArtifacts()) {
dependencyArtifactFiles.add(artifact.getFile());
}
Expand Down Expand Up @@ -799,7 +799,7 @@ protected ImmutableSet<File> makeProtoPathFromJars(
if (temporaryProtoFileDirectory.exists()) {
cleanDirectory(temporaryProtoFileDirectory);
}
final Set<File> protoDirectories = newHashSet();
final Set<File> protoDirectories = new LinkedHashSet<File>();
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)
Expand Down Expand Up @@ -851,7 +851,7 @@ protected ImmutableSet<File> findProtoFilesInDirectory(final File directory) thr

protected ImmutableSet<File> findProtoFilesInDirectories(final Iterable<File> directories) throws IOException {
checkNotNull(directories);
final Set<File> protoFiles = newHashSet();
final Set<File> protoFiles = new LinkedHashSet<File>();
for (final File directory : directories) {
protoFiles.addAll(findProtoFilesInDirectory(directory));
}
Expand Down
8 changes: 4 additions & 4 deletions src/main/java/com/google/protobuf/maven/Protoc.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@
import org.codehaus.plexus.util.cli.Commandline;

import java.io.File;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Set;

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.Lists.newLinkedList;
import static com.google.common.collect.Sets.newHashSet;

/**
* This class represents an invokable configuration of the {@code protoc} compiler.
Expand Down Expand Up @@ -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<File>();
this.protopathElements = new LinkedHashSet<File>();
this.plugins = new LinkedHashSet<ProtocPlugin>();
}

/**
Expand Down

0 comments on commit 5118c50

Please sign in to comment.