rspec/rules/S3009/java/rule.adoc

21 lines
488 B
Plaintext
Raw Normal View History

2021-04-28 16:49:39 +02:00
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.
2021-04-28 16:49:39 +02:00
== Noncompliant Code Example.
----
StringBuilder sb = new StringBuilder();
sb.append("a"); // Noncompliant
----
2021-04-28 16:49:39 +02:00
== Compliant Solution
----
StringBuilder sb = new StringBuilder();
sb.append('a'); // Noncompliant
----