Re: bitfield advantages

From: Jaco van Iterson (J.C.vanIterson@ET.TUDelft.NL)
Date: 03/11/96


On Sat, 9 Mar 1996, Ben Greear wrote:

> 
> 
> I was wondering if you can use the | operator on two identicle
> bit-fields, identical meaning that they are of the same type.
> 
> If so, then they could be very usefull, but if I had to overload the | operator,
> then I see definate performance problems as apposed to using
> regular old ints or long ints.
> 
> All my c and c++ books are very sparse on info pertaining to bitfields...
> 
> perhaps I'll go buy another one :)
> 
> 
> Ben Greear
> 

A bitfield is just a small integer so you can use the | operater on that, but
you probebly mean to use the | operator on a structure with bitfields in it.
This indeed has to be overloaded or done by a macro or function.
The operation will be a little slower but I don't see any problems with
the performance. The | operation is used only once in the bitfield code,
in affect_join if I'm correct.
Setting or resetting bits with bitfields doesn't need the | operation anymore,
you can just set the flag 0 or 1 by using =    (affect.blind = 1;)

Switching your own code over to bitfields is very hard work and I suggest
you only do that when you realy need to do it, if you are running out of
flags and you want to clean up your code. 
It would be very nice if the standard circle code would switch over
to bitfields though.

If you want to check out a mud running on bitfield code try
olympus.ptf.hro.nl 4000

BTW most C books have only sparse info on bitfields, I guess they are not
used that much or autors think there's not much to tell about them.

Jaco



This archive was generated by hypermail 2b30 : 12/07/00 PST