Skip to content

Commit

Permalink
perf(TransformerRegistry): Optimize sorting.
Browse files Browse the repository at this point in the history
  • Loading branch information
priyadi committed Jan 24, 2024
1 parent e8b1677 commit caef4fd
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
## 0.5.17

* fix: Fix static analysis issues.
* perf(`TransformerRegistry`): Optimize sorting.

## 0.5.16

Expand Down
11 changes: 4 additions & 7 deletions src/TransformerRegistry/TransformerRegistry.php
Original file line number Diff line number Diff line change
Expand Up @@ -136,17 +136,14 @@ public function findBySourceAndTargetTypes(
foreach ($targetTypes as $targetType) {
$result = $this->findBySourceAndTargetType($sourceType, $targetType);
foreach ($result as $searchResultEntry) {
$searchResultEntries[] = $searchResultEntry;
$searchResultEntries[$searchResultEntry->getMappingOrder()]
= $searchResultEntry;
}
}
}

usort(
$searchResultEntries,
fn (SearchResultEntry $a, SearchResultEntry $b)
=> $a->getMappingOrder() <=> $b->getMappingOrder()
);
ksort($searchResultEntries, SORT_NUMERIC);

return new SearchResult($searchResultEntries);
return new SearchResult(array_values($searchResultEntries));
}
}

0 comments on commit caef4fd

Please sign in to comment.