mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-08-26 15:27:45 +07:00
GitOrigin-RevId: 8b2b63fc6db476ca0c2cfe5cadd84db6c4236d0f
30 lines
1.0 KiB
HTML
30 lines
1.0 KiB
HTML
<html>
|
|
<body>
|
|
Reports calls to <code>String.startsWith()</code> and
|
|
<code>String.endsWith()</code> where single character string literals are passed as an argument.
|
|
<p>
|
|
A quick-fix is suggested to replace such calls with more efficiently implemented <code>String.charAt()</code>.
|
|
</p>
|
|
<p>
|
|
However, the performance gain of such change is minimal and the code becomes less readable because of the extra non-zero length check,
|
|
so it is recommended to apply the quick-fix only inside tight loops.
|
|
</p>
|
|
<p>
|
|
This inspection is intended for Java ME and other highly resource constrained environments.
|
|
Applying the results of this inspection without consideration might have negative effects on code clarity and design.
|
|
</p>
|
|
<p><b>Example:</b></p>
|
|
<pre><code>
|
|
boolean startsWithX(String s) {
|
|
return s.startsWith("x");
|
|
}
|
|
</code></pre>
|
|
<p>After the quick-fix is applied:</p>
|
|
<pre><code>
|
|
boolean startsWithX(String s) {
|
|
return !s.isEmpty() && s.charAt(0) == 'x';
|
|
}
|
|
</code></pre>
|
|
<!-- tooltip end -->
|
|
</body>
|
|
</html> |