Skip to content

Commit 56ed81d

Browse files
committed
Optimize SequenceMatcher.php sort. The native PHP sort function is sufficient. There is no need for a callback function tupleSort.
1 parent d039186 commit 56ed81d

File tree

2 files changed

+2
-6
lines changed

2 files changed

+2
-6
lines changed

lib/jblond/Diff/DiffUtils.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ class DiffUtils
2323
* @param array $bArray Second array to compare.
2424
*
2525
* @return int -1, 0 or 1, as expected by the usort function.
26+
* @deprecated
2627
*/
2728
public static function tupleSort(array $aArray, array $bArray): int
2829
{

lib/jblond/Diff/SequenceMatcher.php

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -462,12 +462,7 @@ public function getMatchingBlocks(): array
462462
}
463463
}
464464

465-
usort(
466-
$matchingBlocks,
467-
static function ($aArray, $bArray) {
468-
return DiffUtils::tupleSort($aArray, $bArray);
469-
}
470-
);
465+
sort($matchingBlocks);
471466

472467
$i1 = 0;
473468
$j1 = 0;

0 commit comments

Comments
 (0)