On Jan 11, 2025 at 10:53:36 PM, Sven Barth via fpc-pascal <
[email protected]> wrote:
> Set are a minimum of 4 Byte by default cause that's how Delphi does them.
> Ifets you want smaller sets then use the $PackSets directive as Martin had
> written.
>
I did not know this existed. I don’t see any reason they force the set to 4
bytes unless it was being used to pass to C libraries maybe?
> The maximum is also based on what TP and Delphi allow. ISO Pascal for
> example suggests a maximum of 1024 elements instead, though they define
> this number to be implementation specific.
> In the end it's a decision of where to do the cut as at some size the
> majority of the set will be sparsely populated so it makes more sense to
> use a dedicated type instead (e.g. a hash set or something like that) that
> wastes less memory.
>
Theoretically if you added one more element to 257 the size would double to
64 bytes right? That’s still only 50% of a short string both of which can
be sparsely populate so how are they different?
Regards,
Ryan Joseph
_______________________________________________
fpc-pascal maillist - [email protected]
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal