[fpc-devel] Patch to speed up Uppercase/Lowercase functions

Michael Van Canneyt michael at freepascal.org
Sat Jun 11 15:41:58 CEST 2005



On Sat, 11 Jun 2005, Daniël Mantione wrote:

> 
> 
> Op Sat, 11 Jun 2005, schreef Daniël Mantione:
> 
> > > So, judge for yourself. I think this is worth the 256 byte lookup table.
> >
> > ?
> >
> > 0.948/0.999 = 95 %
> >
> > So, we 5% speed improvement from using a table; this is much worse than I
> > thought and can easily be undone in real world by the increased cache
> > trashing. Of course any speed improvement is welcome, but IMHO this is not
> > worth the size increase.
> >
> > Remember, this just 1 procedure, and 256 byte extra is nothing compared to
> > the whole unit.
> >
> > But if we start doing this kind of optimization accross the entire unit,
> > we'll get a horribly bloated unit.
> >
> > Also, if speed is really important, nothing can beat a hand-optimized
> > assembler routine that does the operation without jump and by means of
> > 32-bit registers does 4 chars at once. We have hand optimized string
> > routines in the rtl, I don't see why it cannot be done in sysutils.
> 
> For what it's worth, I found this on my harddrive. It uses
> shortstring, assumes oldfpccall and looking at the code it doesn't look
> that it's possible to process 4 bytes at once this way.

To reduce porting efforts, I would prefer to have sysutils clean of 
assembler code.

I've committed the PChar version without lookup table. 
It gives a nice speed gain (uses only 64% of the time), and doesn't increase the 
size of the executable.

Michael.


More information about the fpc-devel mailing list