Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-devel / 2000-09

class as parameter?

4 messages · 3 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Aleksey V. Vaneev

Hello ,

I don't know how to ask and if that's really a problem... But I'll try..

I have a function that locks (in some medium) an object and returns a real pointer to it.

  So, I have a function:
  function lockObj (Id: DWord): TMyObject;
  And it works just fine! Very fast!
  And if I declare something like this:
  function lockObj (Id: DWord; ExpectClass: TClass): TMyObject;
  It works 8-9 times slower even with the same internal functionality...
  And this really makes me cry... :(

Best regards,
Aleksey

Reply by email

Aleksey V. Vaneev

Hello ,

Sorry for misleading you... The problem was not in class parameter really..

Seems to be AnsiString variables (which I used in the other function) are handled very slowly - dunno maybe it's in their deinitialization or initialization. They are just too damn slowly. I don't know why it is so... I guess if that could be changed overall speed will increase much.

Best regards,
Aleksey

Reply by email

Unknown author
Show quoted text 10 lines
Hello , Sorry for misleading you... The problem was not in class parameter really.. Seems to be AnsiString variables (which I used in the other function) are handled very slowly - dunno maybe it's in their deinitialization or initialization. They are just too damn slowly. I don't know why it is so... I guess if that could be changed overall speed will increase much.

Ansistrings require initialization/finalization and thus (implicit) exception handling in the procedure.

See the difference in the generated code using the -al commandline switch

Peter

Reply by email

Florian Klaempfl
to Unknown author
Show quoted text 13 lines
> Hello , > > Sorry for misleading you... The problem was not in class parameter > really.. > > Seems to be AnsiString variables (which I used in the other > function) are handled very slowly - dunno maybe it's in their > deinitialization or initialization. They are just too damn slowly. I don't > know why it is so... I guess if that could be changed overall speed > will increase much. Ansistrings require initialization/finalization and thus (implicit) exception handling in the procedure.

I've some ideas how this could be improved:
- the exceptaddr record is stored on the stack
- the buf as well
=> saves two new and two dispose calls
- exceptaddr is a threadvar => the thread specific address could be retrieved at procedure entry and stored
on the stack as local var as well

Much better would be a C++ like exception handling implementation with tables but this would require a lot of work.

Reply by email