| Severity | 3 |
|---|---|
| Enabled | yes |
| Waivable | |
| Rationale | StringBuffer with reserved capacity more than default can yield as much as 50% performance improvement in string concatenation operations |
| Violation |
public String concat(String a, String b, String c) {
// VIOLATION
return a+b+c;
}
|
| Fix |
public String concat(String a, String b, String c) {
// FIX
return new StringBuffer(100).append(a).append(b).append(c).toString();
}
|