On 5/23/07, CubicDesign <[EMAIL PROTECTED]> wrote: > > > Ken Adam wrote: > > > > Personally, I would declare it packed, use the types that are defined > not to > > change (as mentioned in another post), and then add 1 byte "reserved" to > make sure > > the structure remained a nice round 16 bytes long to preserve alignment, > and accept that > > this means that it will use 1/15 more disk space than necessary. > > > So, because of this forced 16 bytes alignment the I will have no > performance penalty even if the records are packed. Right? > > > > Alternatively I'd look at whether I really need to store the Boolean > > separately, or could I pack it as 1 bit into one of the other fields. > I don't see the point. If I add an extra byte to force the record length > at 16, then I will have anyway an extra byte that is actually wasted. > So there is no point to 'compress' that byte to 1 bit.
I assume he meant shaving one byte off and store it's value as a bit in another byte, reducing the record to 14 bytes. Whether you pad before or after the field might perhaps also affect performance. > Inserting that extra byte will eat some memory because I have to load > LOTS of those arrays in memory so the memory lost is substantial (length > of the array is about 10000-40000 records). I will see later if the > speed is more important than memory size. Let's see; assuming 40.000 records, that amounts to 40.000 bytes wasted, roughly 40 KB. I'm all for efficient programming, but are those 40 KB that important to you? _______________________________________________ > Delphi mailing list -> [email protected] > http://www.elists.org/mailman/listinfo/delphi > -- www.galdur.net _______________________________________________ Delphi mailing list -> [email protected] http://www.elists.org/mailman/listinfo/delphi

