diff options
author | Matthias Sohn <matthias.sohn@sap.com> | 2023-09-16 22:33:17 +0200 |
---|---|---|
committer | Matthias Sohn <matthias.sohn@sap.com> | 2023-09-22 23:31:28 +0200 |
commit | ec0657ba014585261d3c3c4d69cb905216c5efb5 (patch) | |
tree | 72d4f4fbf9f1bc54c8ecc902ab0b4aa251441ca6 | |
parent | b4f4ae472ab68ac506e634121b20e68931273440 (diff) | |
download | jgit-ec0657ba014585261d3c3c4d69cb905216c5efb5.tar.gz jgit-ec0657ba014585261d3c3c4d69cb905216c5efb5.zip |
[errorprone] Use ArrayList instead of LinkedList
[JdkObsolete] It is very rare for LinkedList to out-perform ArrayList or
ArrayDeque.
see https://errorprone.info/bugpattern/JdkObsolete
Change-Id: I13fb953f55fc7b6e007d6fd6a6a1bfd377773588
3 files changed, 12 insertions, 10 deletions
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/api/AddCommand.java b/org.eclipse.jgit/src/org/eclipse/jgit/api/AddCommand.java index abad766e40..c895dc9aaa 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/api/AddCommand.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/api/AddCommand.java @@ -18,7 +18,7 @@ import static org.eclipse.jgit.lib.FileMode.TYPE_TREE; import java.io.IOException; import java.io.InputStream; import java.time.Instant; -import java.util.LinkedList; +import java.util.ArrayList; import java.util.List; import org.eclipse.jgit.api.errors.FilterFailedException; @@ -73,7 +73,7 @@ public class AddCommand extends GitCommand<DirCache> { */ public AddCommand(Repository repo) { super(repo); - filepatterns = new LinkedList<>(); + filepatterns = new ArrayList<>(); } /** diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/lib/BaseRepositoryBuilder.java b/org.eclipse.jgit/src/org/eclipse/jgit/lib/BaseRepositoryBuilder.java index b2242a11ca..5dfb648faa 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/lib/BaseRepositoryBuilder.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/lib/BaseRepositoryBuilder.java @@ -24,8 +24,8 @@ import static org.eclipse.jgit.lib.Constants.GIT_WORK_TREE_KEY; import java.io.File; import java.io.IOException; import java.text.MessageFormat; +import java.util.ArrayList; import java.util.Collection; -import java.util.LinkedList; import java.util.List; import org.eclipse.jgit.annotations.NonNull; @@ -205,8 +205,9 @@ public class BaseRepositoryBuilder<B extends BaseRepositoryBuilder, R extends Re */ public B addAlternateObjectDirectory(File other) { if (other != null) { - if (alternateObjectDirectories == null) - alternateObjectDirectories = new LinkedList<>(); + if (alternateObjectDirectories == null) { + alternateObjectDirectories = new ArrayList<>(); + } alternateObjectDirectories.add(other); } return self(); @@ -473,8 +474,9 @@ public class BaseRepositoryBuilder<B extends BaseRepositoryBuilder, R extends Re */ public B addCeilingDirectory(File root) { if (root != null) { - if (ceilingDirectories == null) - ceilingDirectories = new LinkedList<>(); + if (ceilingDirectories == null) { + ceilingDirectories = new ArrayList<>(); + } ceilingDirectories.add(root); } return self(); diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/lib/Repository.java b/org.eclipse.jgit/src/org/eclipse/jgit/lib/Repository.java index d446a1c9c7..4722e29b4c 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/lib/Repository.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/lib/Repository.java @@ -15,8 +15,8 @@ package org.eclipse.jgit.lib; -import static org.eclipse.jgit.lib.Constants.LOCK_SUFFIX; import static java.nio.charset.StandardCharsets.UTF_8; +import static org.eclipse.jgit.lib.Constants.LOCK_SUFFIX; import java.io.BufferedOutputStream; import java.io.File; @@ -27,11 +27,11 @@ import java.io.OutputStream; import java.io.UncheckedIOException; import java.net.URISyntaxException; import java.text.MessageFormat; +import java.util.ArrayList; import java.util.Collection; import java.util.Collections; import java.util.HashMap; import java.util.HashSet; -import java.util.LinkedList; import java.util.List; import java.util.Map; import java.util.Set; @@ -1815,7 +1815,7 @@ public abstract class Repository implements AutoCloseable { if (raw == null) return null; - LinkedList<ObjectId> heads = new LinkedList<>(); + List<ObjectId> heads = new ArrayList<>(); for (int p = 0; p < raw.length;) { heads.add(ObjectId.fromString(raw, p)); p = RawParseUtils |