mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-06 23:52:27 +07:00
GitOrigin-RevId: 8b2b63fc6db476ca0c2cfe5cadd84db6c4236d0f
29 lines
916 B
HTML
29 lines
916 B
HTML
<html>
|
|
<body>
|
|
Reports single operations inside loops that could be replaced with a bulk method.
|
|
<p>
|
|
Not only are bulk methods shorter, but in some cases they may be more performant as well.
|
|
</p>
|
|
<p><b>Example:</b></p>
|
|
<pre><code> void test(Collection<Integer> numbers) {
|
|
List<Integer> result = new ArrayList<>();
|
|
for (Integer i : numbers) {
|
|
result.add(i);
|
|
}
|
|
}
|
|
</code></pre>
|
|
<p>After the fix is applied:</p>
|
|
<pre><code>
|
|
void test(Collection<Integer> numbers) {
|
|
List<Integer> result = new ArrayList<>();
|
|
result.addAll(numbers);
|
|
}
|
|
</code></pre>
|
|
<!-- tooltip end -->
|
|
<p>
|
|
The <b>Use Arrays.asList() to wrap arrays</b> option allows to report arrays, even if the bulk method requires a collection.
|
|
In this case the quick-fix will automatically wrap the array in <code>Arrays.asList()</code> call.
|
|
</p>
|
|
<p><small>New in 2017.1</small></p>
|
|
</body>
|
|
</html> |