Skip to content

Commit 291a674

Browse files
committed
Use $size instead of counting on each iteration
1 parent f052c76 commit 291a674

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/Algorithm/Sorting/QuickSort.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
*
55
* Copyright (c) 2018 Dogan Ucar
66
*
7+
* @author Alexey Berezuev <alexey@berezuev.ru>
8+
*
79
* Permission is hereby granted, free of charge, to any person obtaining a copy
810
* of this software and associated documentation files (the "Software"), to deal
911
* in the Software without restriction, including without limitation the rights
@@ -48,7 +50,7 @@ public function sort(array $array): array {
4850
$pivot = $array[0];
4951
$left = $right = [];
5052

51-
for ($i = 1; $i < count($array); $i++) {
53+
for ($i = 1; $i < $size; $i++) {
5254
if (Comparator::lessThan($array[$i], $pivot)) {
5355
$left[] = $array[$i];
5456
} else {

0 commit comments

Comments
 (0)