Re: Biggest Delphi bottleneck?



> (isn't TWinControl message handling done using dynamic methods?).

Yes.

Could you elaborate?

This is the implementation we use for IndexOf, should easily be adaptable to TList and look-alike list containers.

function TObjectList.IndexOf(Item: TObject): Integer;
var
c : Integer;
p : ^TObject;
begin
if (not Assigned(Self)) or (FCount<1) then
Result:=-1
else begin
c:=FCount;
p:=@FList^[0];
asm
mov eax, Item;
mov ecx, c;
mov edx, ecx;
push edi;
mov edi, p;
repne scasd;
je @@FoundIt
mov edx, -1;
jmp @@SetResult;
@@FoundIt:
sub edx, ecx;
dec edx;
@@SetResult:
mov Result, edx;
pop edi;
end;
end;
end;

The "rep" prefix is convenient to use, but isn't as fast as a well designed loop on modern CPUs, so odds are a challenge could come up with a variant that would be faster than this code.

Did some quick googling which turned up some dead links. It seems that
it (FasterTList) was done by FastCoders, but there is nothing about it
on current FastCode site (except "TList.Sort Challenge")?

This link should work:
http://fastcode.cvs.sourceforge.net/*checkout*/fastcode/Source/FasterTList.pas

In GLScene's PersistentClasses.pas unit you'll find a TPersistentObjectList class which should be able to advantageously replace TList/TObjectList straight away in most scenarios.

Eric
.



Relevant Pages