rspec/rules/S3009/java/rule.adoc
2021-04-28 18:08:03 +02:00

21 lines
488 B
Plaintext

It's slightly more efficient to append single characters to ``++StringBuffer++`` and ``++StringBuilder++`` instances as ``++char++``s, than as ``++String++``s. That is, it's more efficient to put a single ``++char++`` in single quotes, rather than double quotes.
== Noncompliant Code Example.
----
StringBuilder sb = new StringBuilder();
sb.append("a"); // Noncompliant
----
== Compliant Solution
----
StringBuilder sb = new StringBuilder();
sb.append('a'); // Noncompliant
----