On Tue, 13 Nov 2007, Sam Liddicott wrote:

> Michael Van Canneyt wrote:
> > On Tue, 13 Nov 2007, Graeme Geldenhuys wrote:
> >   
> > >   *  They tend to be slow compared no native types. In
> > >       Delphi 6 they were very slow. How does it compare
> > >       in FPC 2.2.0?
> > >     
> >
> > They are slower than native types, there is no way around this.
> > Almost each and every operation involving variants has some implicit calls
> > to variant support routines.
> >   
> If the variant type is the correct type, no casts are done and the whole thing
> is very quick.

Exactly: IF. 

this means
a) Check if. This by itself involves a call to a helper routine.
b) convert if not the same

With native types it's just a straight copy.


> > You should see that it is more than double the size.
> > If that doesn't convince someone that variants are SLOW, then I don't know
> > what will. Use -al for compiler options.
> >   
> Twice as big doesn't mean slow at all.

Just have a look at the code before saying that :-)

> Most of the extra code covers different branches based on the variant type,
> most of the extra code is NEVER used but there "in case" because, as you say,
> pascal is a type safe language.

It must be checked, each time over and over again. Just look at the code.

> I would much rather have pascal manage the variant and conversions for me than
> I have to manage it and get it wrong.

The point is that you don't need to do conversions when using typed variables.

Michael.

_________________________________________________________________
     To unsubscribe: mail [EMAIL PROTECTED] with
                "unsubscribe" as the Subject
   archives at http://www.lazarus.freepascal.org/mailarchives

Reply via email to