1.2.1138. Skip Empty Array When Merging¶
When merging arrays that were collected, it is faster to skip the empty arrays, rather than let array_merge()
process them. This also works with array_merge_recursive().
This is a micro-optimisation. It is more efficient with larger arrays.
<?php
$all = [];
foreach($source as $array) {
// $array is an array in this example
if (empty($array)) {
continue;
}
$all[] = $array;
}
$all = array_merge(...$all);
?>
1.2.1138.1. Connex PHP features¶
1.2.1138.1.1. Specs¶
Short name |
Performances/SkipEmptyArray |
Rulesets |
|
Exakat since |
2.5.0 |
PHP Version |
All |
Severity |
Minor |
Time To Fix |
Quick (30 mins) |
Precision |
Medium |
Available in |