|
@@ -933,7 +933,7 @@ end;
|
|
|
|
|
|
{$if not defined(FPC_TESTGENERICS)}
|
|
{$if not defined(FPC_TESTGENERICS)}
|
|
|
|
|
|
-Procedure TStringList.ExchangeItems(Index1, Index2: Integer);
|
|
|
|
|
|
+Procedure TStringList.ExchangeItemsInt(Index1, Index2: Integer);
|
|
|
|
|
|
Var P1,P2 : Pointer;
|
|
Var P1,P2 : Pointer;
|
|
|
|
|
|
@@ -947,6 +947,11 @@ begin
|
|
end;
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
+Procedure TStringList.ExchangeItems(Index1, Index2: Integer);
|
|
|
|
+begin
|
|
|
|
+ ExchangeItemsInt(Index1, Index2);
|
|
|
|
+end;
|
|
|
|
+
|
|
|
|
|
|
Procedure TStringList.Grow;
|
|
Procedure TStringList.Grow;
|
|
|
|
|
|
@@ -991,11 +996,18 @@ end;
|
|
Procedure TStringList.QuickSort(L, R: Integer; CompareFn: TStringListSortCompare);
|
|
Procedure TStringList.QuickSort(L, R: Integer; CompareFn: TStringListSortCompare);
|
|
var
|
|
var
|
|
Pivot, vL, vR: Integer;
|
|
Pivot, vL, vR: Integer;
|
|
|
|
+ ExchangeProc: procedure(Left, Right: Integer) of object;
|
|
begin
|
|
begin
|
|
|
|
+ //if ExchangeItems is override call that, else call (faster) ExchangeItemsInt
|
|
|
|
+ if TMethod(@Self.ExchangeItems).Code = Pointer(@TStringList.ExchangeItems) then
|
|
|
|
+ ExchangeProc := @ExchangeItemsInt
|
|
|
|
+ else
|
|
|
|
+ ExchangeProc := @ExchangeItems;
|
|
|
|
+
|
|
if R - L <= 1 then begin // a little bit of time saver
|
|
if R - L <= 1 then begin // a little bit of time saver
|
|
if L < R then
|
|
if L < R then
|
|
if CompareFn(Self, L, R) > 0 then
|
|
if CompareFn(Self, L, R) > 0 then
|
|
- ExchangeItems(L, R);
|
|
|
|
|
|
+ ExchangeProc(L, R);
|
|
|
|
|
|
Exit;
|
|
Exit;
|
|
end;
|
|
end;
|
|
@@ -1012,7 +1024,7 @@ begin
|
|
while (vR > Pivot) and (CompareFn(Self, vR, Pivot) > 0) do
|
|
while (vR > Pivot) and (CompareFn(Self, vR, Pivot) > 0) do
|
|
Dec(vR);
|
|
Dec(vR);
|
|
|
|
|
|
- ExchangeItems(vL, vR);
|
|
|
|
|
|
+ ExchangeProc(vL, vR);
|
|
|
|
|
|
if Pivot = vL then // swap pivot if we just hit it from one side
|
|
if Pivot = vL then // swap pivot if we just hit it from one side
|
|
Pivot := vR
|
|
Pivot := vR
|
|
@@ -1258,7 +1270,7 @@ begin
|
|
If (Index2<0) or (Index2>=FCount) then
|
|
If (Index2<0) or (Index2>=FCount) then
|
|
Error(SListIndexError,Index2);
|
|
Error(SListIndexError,Index2);
|
|
Changing;
|
|
Changing;
|
|
- ExchangeItems(Index1,Index2);
|
|
|
|
|
|
+ ExchangeItemsInt(Index1,Index2);
|
|
changed;
|
|
changed;
|
|
end;
|
|
end;
|
|
|
|
|