[fpc-pascal] bitmask vs sets. Is there a performance difference?

Nikolay Nikolov nickysn at gmail.com
Thu Jan 21 12:19:29 CET 2016



On 01/21/2016 01:11 AM, Sven Barth wrote:
>
> Am 20.01.2016 19:26 schrieb "Graeme Geldenhuys" 
> <mailinglists at geldenhuys.co.uk <mailto:mailinglists at geldenhuys.co.uk>>:
> >
> > Is there a performance difference between using bitmask values and sets?
>
> For sets with <= 32 elements it should behave the same if I remember 
> correctly (I don't know right now though whether it would be 64 
> elements on 64-bit platforms though). With more elements there will be 
> a penalty as then helper routines are needed.
> You cam check this by compiling with -al and comparing the assembler 
> code. :)
>
> >
> > While we are on the topic of Sets. What is the maximum number of values
> > you may have in a set, and does it differ between 32-bit and 64-bit
> > platforms?
>
> The maximum is currently 256 and it's the same on both platforms.
>
I think you can have even larger sets, but they are not supported by the 
RTTI functions and the FCL streaming system. Also, if you are using sets 
larger than 32 elements, the default value for {$packset} is not very 
optimal, as it will waste space for 256 elements, even if you need only 
33. So, you're better off using something like {$packset 4}. The default 
setting is only kept for backward compatibility.

Nikolay
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20160121/6da0d527/attachment.html>


More information about the fpc-pascal mailing list