38 lines
767 B
Plaintext
38 lines
767 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
|
|
|
|
[source,java]
|
|
----
|
|
StringBuilder sb = new StringBuilder();
|
|
|
|
sb.append("a"); // Noncompliant
|
|
----
|
|
|
|
|
|
== Compliant Solution
|
|
|
|
[source,java]
|
|
----
|
|
StringBuilder sb = new StringBuilder();
|
|
|
|
sb.append('a'); // Noncompliant
|
|
----
|
|
|
|
|
|
ifdef::env-github,rspecator-view[]
|
|
|
|
'''
|
|
== Implementation Specification
|
|
(visible only on this page)
|
|
|
|
include::message.adoc[]
|
|
|
|
'''
|
|
== Comments And Links
|
|
(visible only on this page)
|
|
|
|
include::comments-and-links.adoc[]
|
|
endif::env-github,rspecator-view[]
|