Use StringBuilder to concatenate strings. #1555
Fixes `StringReplaceableByStringBuffer` inspection violations. Description: Reports any variables declared as java.lang.String which are repeatedly appended to. Such variables may be more efficiently declared as java.lang.StringBuffer or java.lang.StringBuilder.
This commit is contained in:
parent
b550547318
commit
bf6735ce4b
|
|
@ -233,6 +233,7 @@ public class ImportOrderCheck
|
|||
|
||||
for (int i = 0; i < packageGroups.length; i++) {
|
||||
String pkg = packageGroups[i];
|
||||
final StringBuilder pkgBuilder = new StringBuilder(pkg);
|
||||
Pattern grp;
|
||||
|
||||
// if the pkg name is the wildcard, make it match zero chars
|
||||
|
|
@ -249,9 +250,9 @@ public class ImportOrderCheck
|
|||
}
|
||||
else {
|
||||
if (!Utils.endsWithChar(pkg, '.')) {
|
||||
pkg += ".";
|
||||
pkgBuilder.append('.');
|
||||
}
|
||||
grp = Pattern.compile("^" + Pattern.quote(pkg));
|
||||
grp = Pattern.compile("^" + Pattern.quote(pkgBuilder.toString()));
|
||||
}
|
||||
|
||||
groups[i] = grp;
|
||||
|
|
|
|||
Loading…
Reference in New Issue