Browse Source

Use Arrays.asList instead of copying array in a for loop

Change-Id: Ie44950f7d2f2f94a0412efb6c274f6e1e31efcd6
Signed-off-by: Carsten Hammer <carsten.hammer@t-online.de>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
stable-5.4
Carsten Hammer 6 years ago committed by Matthias Sohn
parent
commit
0b320b2c35
  1. 5
      org.eclipse.jgit.ssh.apache/src/org/eclipse/jgit/internal/transport/sshd/OpenSshServerKeyVerifier.java
  2. 4
      org.eclipse.jgit.test/src/org/eclipse/jgit/lib/Sets.java
  3. 4
      org.eclipse.jgit.test/tst/org/eclipse/jgit/attributes/TreeWalkAttributeTest.java
  4. 4
      org.eclipse.jgit/src/org/eclipse/jgit/api/DeleteBranchCommand.java
  5. 4
      org.eclipse.jgit/src/org/eclipse/jgit/api/DeleteTagCommand.java
  6. 7
      org.eclipse.jgit/src/org/eclipse/jgit/revwalk/filter/RevFlagFilter.java
  7. 5
      org.eclipse.jgit/src/org/eclipse/jgit/transport/BasePackConnection.java

5
org.eclipse.jgit.ssh.apache/src/org/eclipse/jgit/internal/transport/sshd/OpenSshServerKeyVerifier.java

@ -60,6 +60,7 @@ import java.nio.file.Paths;
import java.security.GeneralSecurityException;
import java.security.PublicKey;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.LinkedList;
@ -586,9 +587,7 @@ public class OpenSshServerKeyVerifier
KeyUtils.getFingerPrint(BuiltinDigests.sha256, expected),
KeyUtils.getFingerPrint(BuiltinDigests.md5, actual),
KeyUtils.getFingerPrint(BuiltinDigests.sha256, actual));
for (String line : warning.split("\n")) { //$NON-NLS-1$
messages.add(line);
}
messages.addAll(Arrays.asList(warning.split("\n"))); //$NON-NLS-1$
CredentialsProvider provider = getCredentialsProvider(
clientSession);

4
org.eclipse.jgit.test/src/org/eclipse/jgit/lib/Sets.java

@ -43,6 +43,7 @@
package org.eclipse.jgit.lib;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;
@ -50,8 +51,7 @@ public class Sets {
@SafeVarargs
public static <T> Set<T> of(T... elements) {
Set<T> ret = new HashSet<>();
for (T element : elements)
ret.add(element);
ret.addAll(Arrays.asList(elements));
return ret;
}
}

4
org.eclipse.jgit.test/tst/org/eclipse/jgit/attributes/TreeWalkAttributeTest.java

@ -49,6 +49,7 @@ import static org.junit.Assert.assertTrue;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.HashSet;
@ -854,8 +855,7 @@ public class TreeWalkAttributeTest extends RepositoryTestCase {
static Set<Attribute> asSet(Attribute... attrs) {
HashSet<Attribute> result = new HashSet<>();
for (Attribute attr : attrs)
result.add(attr);
result.addAll(Arrays.asList(attrs));
return result;
}

4
org.eclipse.jgit/src/org/eclipse/jgit/api/DeleteBranchCommand.java

@ -46,6 +46,7 @@ package org.eclipse.jgit.api;
import java.io.IOException;
import java.text.MessageFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
@ -188,8 +189,7 @@ public class DeleteBranchCommand extends GitCommand<List<String>> {
public DeleteBranchCommand setBranchNames(String... branchnames) {
checkCallable();
this.branchNames.clear();
for (String branch : branchnames)
this.branchNames.add(branch);
this.branchNames.addAll(Arrays.asList(branchnames));
return this;
}

4
org.eclipse.jgit/src/org/eclipse/jgit/api/DeleteTagCommand.java

@ -45,6 +45,7 @@ package org.eclipse.jgit.api;
import java.io.IOException;
import java.text.MessageFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
@ -135,8 +136,7 @@ public class DeleteTagCommand extends GitCommand<List<String>> {
public DeleteTagCommand setTags(String... tags) {
checkCallable();
this.tags.clear();
for (String tagName : tags)
this.tags.add(tagName);
this.tags.addAll(Arrays.asList(tags));
return this;
}
}

7
org.eclipse.jgit/src/org/eclipse/jgit/revwalk/filter/RevFlagFilter.java

@ -44,6 +44,7 @@
package org.eclipse.jgit.revwalk.filter;
import java.io.IOException;
import java.util.Arrays;
import org.eclipse.jgit.errors.IncorrectObjectTypeException;
import org.eclipse.jgit.errors.MissingObjectException;
@ -78,8 +79,7 @@ public abstract class RevFlagFilter extends RevFilter {
*/
public static RevFilter hasAll(RevFlag... a) {
final RevFlagSet set = new RevFlagSet();
for (RevFlag flag : a)
set.add(flag);
set.addAll(Arrays.asList(a));
return new HasAll(set);
}
@ -103,8 +103,7 @@ public abstract class RevFlagFilter extends RevFilter {
*/
public static RevFilter hasAny(RevFlag... a) {
final RevFlagSet set = new RevFlagSet();
for (RevFlag flag : a)
set.add(flag);
set.addAll(Arrays.asList(a));
return new HasAny(set);
}

5
org.eclipse.jgit/src/org/eclipse/jgit/transport/BasePackConnection.java

@ -53,6 +53,7 @@ import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.text.MessageFormat;
import java.util.Arrays;
import java.util.HashSet;
import java.util.LinkedHashMap;
import java.util.Set;
@ -214,8 +215,8 @@ abstract class BasePackConnection extends BaseConnection {
if (nul >= 0) {
// The first line (if any) may contain "hidden"
// capability values after a NUL byte.
for (String c : line.substring(nul + 1).split(" ")) //$NON-NLS-1$
remoteCapablities.add(c);
remoteCapablities.addAll(
Arrays.asList(line.substring(nul + 1).split(" "))); //$NON-NLS-1$
line = line.substring(0, nul);
}
}

Loading…
Cancel
Save