On approximately 10/8/2004 10:42 AM, came the following characters from the keyboard of Laurent ROCHER:

Oups, correct and test it too fast :o)

Yes, and I could see there was a problem, but it took me 3 tries to describe it properly! So I understand the problems of doing things too fast. Glad we have a list and can work things out together. And thanks for fixing it again :)

It's work when i test because center is default.

Yes, that test case would work.

#define SetBits(mask, bits)  {mask |= bits;}
#define ResetBits(mask, bits)  {mask &= ~(bits);}
#define SwitchBits(mask, bits, set) \
 {if (set) SetBits(mask,bits) else ResetBits(mask,bits);}


Yes, you right. I keep this for later. I don't want to add more stuff now but only bug correction.

Understood. And I think the above is correct, but I didn't test them. Except that memory reads are faster than memory writes, I'm not sure that the extra conditionals in the current version of SwitchBit (notice I changed the name from SwitchBit to SwitchBits in the above, so they could coexist) are an optimization. Fewer instructions and fewer branches would be generated by the code above.. but one more memory store guaranteed to be performed by the above, which is made optional by the current SwitchBit code with the extra conditionals.

--
Glenn -- http://nevcal.com/
===========================
The best part about procrastination is that you are never bored,
because you have all kinds of things that you should be doing.

Reply via email to