On Aug 13, 6:05 am, ajk <ander...@gmail.comwrote:
On Aug 13, 11:16 am, "Alf P. Steinbach" <al...@start.nowrote:
[...]
in the original class where I found this it looks like
class F
{
<<...>>
bool a:1;
bool b:1;
bool c:1;
bool d:1;
<<some other declarations not bools and not using bitspec.>>
};
Might be efficiency, if these F's are passed around by value
in zillions of calls, or memory consumption if a quadzillion
of them are in an array, or matching layout of some lower
level API or hardware.
Otherwise it just wastes both programmer and program time.
Difficult to say without more context info.
the context is a compiler, so normally this would mean a one
time buildup of an abstract syntax tree where each tree node
has 4 of these bool's. I think we are talking about max a few
thousand nodes so all in all it seems useless.
(More likely a few tens of thousands of nodes, or even hundreds
of thousands. But still a lot less that the zillions Alf
mentioned.)
It's probably a waste of time today. It might have been less
useless back in the days of 16 bit machines, and might be a
holdover from then. (While it wastes programmer time to write
it when you don't need it, if you already have it, it's probably
not worth the programmer time to change it.) Or just a
programmer who got into the habit back then, and hasn't evolved.
Conceivably, if there's a special allocator for F, which ensures
locality, it might reduce cache misses and page faults some, but
I'd be fairly surprised if it made a noticeable difference.
--
James Kanze (GABI Software) email:ja*********@gmail.com
Conseils en informatique orientée objet/
Beratung in objektorientierter Datenverarbeitung
9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34