Explorar el Código

* partition elements equal to the pivot on both sides of the pivot, since that
leads to much better performance when sorting lots of repeating elements

git-svn-id: trunk@41231 -

nickysn hace 6 años
padre
commit
eca60a0a89
Se han modificado 1 ficheros con 4 adiciones y 4 borrados
  1. 4 4
      rtl/inc/sortbase.pp

+ 4 - 4
rtl/inc/sortbase.pp

@@ -76,7 +76,7 @@ begin
    PivotIdx := (L + R) div 2;
    P := ItemPtrs[PivotIdx];
    repeat
-     while (I < PivotIdx) and (Comparer(P, ItemPtrs[i]) >= 0) do
+     while (I < PivotIdx) and (Comparer(P, ItemPtrs[i]) > 0) do
        Inc(I);
      while (J > PivotIdx) and (Comparer(P, ItemPtrs[J]) < 0) do
        Dec(J);
@@ -143,7 +143,7 @@ procedure QuickSort_PtrList_Context(ItemPtrs: PPointer; ItemCount: SizeUInt; Com
       PivotIdx := (L + R) div 2;
       P := ItemPtrs[PivotIdx];
       repeat
-        while (I < PivotIdx) and (Comparer(P, ItemPtrs[I], Context) >= 0) do
+        while (I < PivotIdx) and (Comparer(P, ItemPtrs[I], Context) > 0) do
           Inc(I);
         while (J > PivotIdx) and (Comparer(P, ItemPtrs[J], Context) < 0) do
           Dec(J);
@@ -212,7 +212,7 @@ var
       PivotIdx := (L + R) div 2;
       P := Items + ItemSize*PivotIdx;
       repeat
-        while (I < PivotIdx) and (Comparer(P, Items + ItemSize*I, Context) >= 0) do
+        while (I < PivotIdx) and (Comparer(P, Items + ItemSize*I, Context) > 0) do
           Inc(I);
         while (J > PivotIdx) and (Comparer(P, Items + ItemSize*J, Context) < 0) do
           Dec(J);
@@ -290,7 +290,7 @@ procedure QuickSort_ItemList_CustomItemExchanger_Context(
       PivotIdx := (L + R) div 2;
       P := Items + ItemSize*PivotIdx;
       repeat
-        while (I < PivotIdx) and (Comparer(P, Items + ItemSize*I, Context) >= 0) do
+        while (I < PivotIdx) and (Comparer(P, Items + ItemSize*I, Context) > 0) do
           Inc(I);
         while (J > PivotIdx) and (Comparer(P, Items + ItemSize*J, Context) < 0) do
           Dec(J);