All Downloads are FREE. Search and download functionalities are using the official Maven repository.

resources.report.rules.pmd.ConsecutiveAppendsShouldReuse.html Maven / Gradle / Ivy



ConsecutiveAppendsShouldReuse

ConsecutiveAppendsShouldReuse

Consecutive calls to StringBuffer/StringBuilder .append should be chained, reusing the target object. This can improve the performance by producing a smaller bytecode, reducing overhead and improving inlining. A complete analysis can be found here

This rule is defined by the following Java class: net.sourceforge.pmd.lang.java.rule.strings.ConsecutiveAppendsShouldReuseRule

Example(s):


String foo = " ";

StringBuffer buf = new StringBuffer();
buf.append("Hello"); // poor
buf.append(foo);
buf.append("World");

StringBuffer buf = new StringBuffer();
buf.append("Hello").append(foo).append("World"); // good





© 2015 - 2024 Weber Informatics LLC | Privacy Policy