mirror of
https://github.com/danog/psalm.git
synced 2024-11-30 04:39:00 +01:00
Improve shuffling
This commit is contained in:
parent
7e76d3386d
commit
e1e2ff3e57
@ -361,36 +361,36 @@ class Analyzer
|
||||
};
|
||||
|
||||
if ($pool_size > 1 && count($this->files_to_analyze) > $pool_size) {
|
||||
$process_file_paths = [];
|
||||
$shuffle_count = $pool_size + 1;
|
||||
|
||||
$i = 0;
|
||||
$file_paths = \array_values($this->files_to_analyze);
|
||||
|
||||
foreach ($this->files_to_analyze as $file_path) {
|
||||
$process_file_paths[$i % $pool_size][] = $file_path;
|
||||
++$i;
|
||||
}
|
||||
|
||||
foreach ($process_file_paths as $pool_key => $file_paths) {
|
||||
$count = count($file_paths);
|
||||
$middle = \intdiv($count, 4);
|
||||
$remainder = $count % 4;
|
||||
$middle = \intdiv($count, $shuffle_count);
|
||||
$remainder = $count % $shuffle_count;
|
||||
|
||||
$new_file_paths = [];
|
||||
|
||||
for ($i = 0; $i < 4; $i++) {
|
||||
for ($i = 0; $i < $shuffle_count; $i++) {
|
||||
for ($j = 0; $j < $middle; $j++) {
|
||||
if ($j * 4 + $i < $count) {
|
||||
$new_file_paths[] = $file_paths[$j * 4 + $i];
|
||||
if ($j * $shuffle_count + $i < $count) {
|
||||
$new_file_paths[] = $file_paths[$j * $shuffle_count + $i];
|
||||
}
|
||||
}
|
||||
|
||||
if ($remainder) {
|
||||
$new_file_paths[] = $file_paths[$middle * 4 + $remainder - 1];
|
||||
$new_file_paths[] = $file_paths[$middle * $shuffle_count + $remainder - 1];
|
||||
$remainder--;
|
||||
}
|
||||
}
|
||||
|
||||
$process_file_paths[$pool_key] = $new_file_paths;
|
||||
$process_file_paths = [];
|
||||
|
||||
$i = 0;
|
||||
|
||||
foreach ($file_paths as $file_path) {
|
||||
$process_file_paths[$i % $pool_size][] = $file_path;
|
||||
++$i;
|
||||
}
|
||||
|
||||
// Run analysis one file at a time, splitting the set of
|
||||
|
Loading…
Reference in New Issue
Block a user