src/main/java/com/github/koraktor/mavanagaiata/mojo/TagMojo.java
Prefer StringBuilder (non-synchronized) or StringBuffer (synchronized) over += for concatenating strings Open
Open
describe += dirtyFlag;
- Read upRead up
- Exclude checks
UseStringBufferForStringAppends
Since: PMD 3.1
Priority: Medium
Categories: Style
Remediation Points: 50000
The use of the '+=' operator for appending strings causes the JVM to create and use an internal StringBuffer. If a non-trivial number of these concatenations are being used then the explicit use of a StringBuilder or threadsafe StringBuffer is recommended to avoid this.
Example:
public class Foo {
void bar() {
String a;
a = 'foo';
a += ' bar';
// better would be:
// StringBuilder a = new StringBuilder('foo');
// a.append(' bar');
}
}