Use StringBuilder.append(char) where possible
To slightly improve performance, this commit switches to StringBuilder.append(char) instead of StringBuilder.append(String) whenever we append a single character to a StringBuilder. Closes gh-27098
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
* Copyright 2002-2021 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -194,7 +194,7 @@ class FastByteArrayOutputStreamTests {
|
||||
this.os.write(this.helloBytes);
|
||||
InputStream inputStream = this.os.getInputStream();
|
||||
DigestUtils.appendMd5DigestAsHex(inputStream, builder);
|
||||
builder.append("\"");
|
||||
builder.append('"');
|
||||
String actual = builder.toString();
|
||||
assertThat(actual).isEqualTo("\"0b10a8db164e0754105b7a99be72e3fe5\"");
|
||||
}
|
||||
@@ -208,7 +208,7 @@ class FastByteArrayOutputStreamTests {
|
||||
}
|
||||
InputStream inputStream = this.os.getInputStream();
|
||||
DigestUtils.appendMd5DigestAsHex(inputStream, builder);
|
||||
builder.append("\"");
|
||||
builder.append('"');
|
||||
String actual = builder.toString();
|
||||
assertThat(actual).isEqualTo("\"06225ca1e4533354c516e74512065331d\"");
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2020 the original author or authors.
|
||||
* Copyright 2002-2021 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -612,7 +612,7 @@ class StringUtilsTests {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (int i = 0; i < components.length; i++) {
|
||||
if (i != 0) {
|
||||
sb.append(",");
|
||||
sb.append(',');
|
||||
}
|
||||
sb.append(components[i]);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user