summaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit.pgm.test
diff options
context:
space:
mode:
authorDavid Pursehouse <david.pursehouse@gmail.com>2016-10-19 12:54:46 +0900
committerDavid Pursehouse <david.pursehouse@gmail.com>2016-10-19 15:09:31 +0900
commit8f9e157cd5093bf8097f0b6defdef530de761e07 (patch)
tree07dcf070c89b6346406020041788f21432cf2c98 /org.eclipse.jgit.pgm.test
parent9ed2d949bb9db2ff2abf1d4c7980933ce0914b28 (diff)
downloadjgit-8f9e157cd5093bf8097f0b6defdef530de761e07.tar.gz
jgit-8f9e157cd5093bf8097f0b6defdef530de761e07.zip
ArchiveTest: Don't use string concatenation in loop
According to FindBugs: In each iteration, the String is converted to a StringBuffer/ StringBuilder, appended to, and converted back to a String. This can lead to a cost quadratic in the number of iterations, as the growing string is recopied in each iteration. Replace string concatenation with StringBuffer. Change-Id: I60e09f274bed6722f4e0e4d096b0f2b1b31ec1b4 Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
Diffstat (limited to 'org.eclipse.jgit.pgm.test')
-rw-r--r--org.eclipse.jgit.pgm.test/tst/org/eclipse/jgit/pgm/ArchiveTest.java24
1 files changed, 12 insertions, 12 deletions
diff --git a/org.eclipse.jgit.pgm.test/tst/org/eclipse/jgit/pgm/ArchiveTest.java b/org.eclipse.jgit.pgm.test/tst/org/eclipse/jgit/pgm/ArchiveTest.java
index a503ffdad0..35467c6304 100644
--- a/org.eclipse.jgit.pgm.test/tst/org/eclipse/jgit/pgm/ArchiveTest.java
+++ b/org.eclipse.jgit.pgm.test/tst/org/eclipse/jgit/pgm/ArchiveTest.java
@@ -528,15 +528,15 @@ public class ArchiveTest extends CLIRepositoryTestCase {
@Test
public void testArchiveWithLongFilename() throws Exception {
- String filename = "";
+ StringBuilder filename = new StringBuilder();
List<String> l = new ArrayList<String>();
for (int i = 0; i < 20; i++) {
- filename = filename + "1234567890/";
- l.add(filename);
+ filename.append("1234567890/");
+ l.add(filename.toString());
}
- filename = filename + "1234567890";
- l.add(filename);
- writeTrashFile(filename, "file with long path");
+ filename.append("1234567890");
+ l.add(filename.toString());
+ writeTrashFile(filename.toString(), "file with long path");
git.add().addFilepattern("1234567890").call();
git.commit().setMessage("file with long name").call();
@@ -548,15 +548,15 @@ public class ArchiveTest extends CLIRepositoryTestCase {
@Test
public void testTarWithLongFilename() throws Exception {
- String filename = "";
+ StringBuilder filename = new StringBuilder();
List<String> l = new ArrayList<String>();
for (int i = 0; i < 20; i++) {
- filename = filename + "1234567890/";
- l.add(filename);
+ filename.append("1234567890/");
+ l.add(filename.toString());
}
- filename = filename + "1234567890";
- l.add(filename);
- writeTrashFile(filename, "file with long path");
+ filename.append("1234567890");
+ l.add(filename.toString());
+ writeTrashFile(filename.toString(), "file with long path");
git.add().addFilepattern("1234567890").call();
git.commit().setMessage("file with long name").call();