mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-21 12:13:12 +02:00
* Added performance improvements suggested by Mattias Gaertner
- list grows in steps of 25% if size >= 128 - list shrinks by 50% if size drops below a quarter of the capacity
This commit is contained in:
parent
aa344936d1
commit
624a27a081
@ -126,6 +126,13 @@ begin
|
|||||||
Error (SListIndexError,Index);
|
Error (SListIndexError,Index);
|
||||||
FCount:=FCount-1;
|
FCount:=FCount-1;
|
||||||
System.Move (FList^[Index+1],FList^[Index],(FCount-Index)*SizeOf(Pointer));
|
System.Move (FList^[Index+1],FList^[Index],(FCount-Index)*SizeOf(Pointer));
|
||||||
|
|
||||||
|
// Shrink the list if appropiate
|
||||||
|
if (FCapacity > 256) and (FCount < FCapacity shr 2) then
|
||||||
|
begin
|
||||||
|
FCapacity := FCapacity shr 1;
|
||||||
|
ReallocMem(FList, SizeOf(Pointer) * FCapacity);
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
@ -160,6 +167,7 @@ begin
|
|||||||
IncSize:=4;
|
IncSize:=4;
|
||||||
if FCapacity>3 then IncSize:=IncSize+4;
|
if FCapacity>3 then IncSize:=IncSize+4;
|
||||||
if FCapacity>8 then IncSize:=IncSize+8;
|
if FCapacity>8 then IncSize:=IncSize+8;
|
||||||
|
if FCapacity>127 then Inc(IncSize, FCapacity shr 2);
|
||||||
SetCapacity(FCapacity+IncSize);
|
SetCapacity(FCapacity+IncSize);
|
||||||
Result:=Self;
|
Result:=Self;
|
||||||
end;
|
end;
|
||||||
@ -399,7 +407,12 @@ end;
|
|||||||
|
|
||||||
{
|
{
|
||||||
$Log$
|
$Log$
|
||||||
Revision 1.4 2000-11-17 13:39:49 sg
|
Revision 1.5 2001-07-17 22:07:29 sg
|
||||||
|
* Added performance improvements suggested by Mattias Gaertner
|
||||||
|
- list grows in steps of 25% if size >= 128
|
||||||
|
- list shrinks by 50% if size drops below a quarter of the capacity
|
||||||
|
|
||||||
|
Revision 1.4 2000/11/17 13:39:49 sg
|
||||||
* Extended Error methods so that exceptions are raised from the caller's
|
* Extended Error methods so that exceptions are raised from the caller's
|
||||||
address instead of the Error method
|
address instead of the Error method
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user