Skip to content

Commit fd189e0

Browse files
committed
tentative performance optimization (needs benchmarks)
1 parent de1c9a9 commit fd189e0

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/SelectTree.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,10 @@ private function buildTreeFromResults($results, $parent = null): Collection
246246
);
247247

248248
// Move any remaining children from the cache into the root of the tree, since their parents do not show up in the result set
249-
$resultMap[$parent] = array_merge(...array_values($orphanedResults));
249+
$resultMap[$parent] = [];
250+
foreach($orphanedResults as $orphanedResult){
251+
$resultMap[$parent] += $orphanedResult;
252+
}
250253

251254
// Recursively build the tree starting from the root (null parent)
252255
$rootResults = $resultMap[$parent] ?? [];

0 commit comments

Comments
 (0)