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>
This commit is contained in:
parent
9ed2d949bb
commit
8f9e157cd5
|
@ -528,15 +528,15 @@ public void testTarPreservesMode() throws Exception {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testArchiveWithLongFilename() throws Exception {
|
public void testArchiveWithLongFilename() throws Exception {
|
||||||
String filename = "";
|
StringBuilder filename = new StringBuilder();
|
||||||
List<String> l = new ArrayList<String>();
|
List<String> l = new ArrayList<String>();
|
||||||
for (int i = 0; i < 20; i++) {
|
for (int i = 0; i < 20; i++) {
|
||||||
filename = filename + "1234567890/";
|
filename.append("1234567890/");
|
||||||
l.add(filename);
|
l.add(filename.toString());
|
||||||
}
|
}
|
||||||
filename = filename + "1234567890";
|
filename.append("1234567890");
|
||||||
l.add(filename);
|
l.add(filename.toString());
|
||||||
writeTrashFile(filename, "file with long path");
|
writeTrashFile(filename.toString(), "file with long path");
|
||||||
git.add().addFilepattern("1234567890").call();
|
git.add().addFilepattern("1234567890").call();
|
||||||
git.commit().setMessage("file with long name").call();
|
git.commit().setMessage("file with long name").call();
|
||||||
|
|
||||||
|
@ -548,15 +548,15 @@ public void testArchiveWithLongFilename() throws Exception {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testTarWithLongFilename() throws Exception {
|
public void testTarWithLongFilename() throws Exception {
|
||||||
String filename = "";
|
StringBuilder filename = new StringBuilder();
|
||||||
List<String> l = new ArrayList<String>();
|
List<String> l = new ArrayList<String>();
|
||||||
for (int i = 0; i < 20; i++) {
|
for (int i = 0; i < 20; i++) {
|
||||||
filename = filename + "1234567890/";
|
filename.append("1234567890/");
|
||||||
l.add(filename);
|
l.add(filename.toString());
|
||||||
}
|
}
|
||||||
filename = filename + "1234567890";
|
filename.append("1234567890");
|
||||||
l.add(filename);
|
l.add(filename.toString());
|
||||||
writeTrashFile(filename, "file with long path");
|
writeTrashFile(filename.toString(), "file with long path");
|
||||||
git.add().addFilepattern("1234567890").call();
|
git.add().addFilepattern("1234567890").call();
|
||||||
git.commit().setMessage("file with long name").call();
|
git.commit().setMessage("file with long name").call();
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue