On 05.03.2010, at 19:41, Duncan Gibson wrote:

> Maybe it isn't fast and light enough, but a lot of code would be
> improved by simply introducing a temporary local variable with an
> informative name. A good compiler should just optimize it away.
>
> Flags descriptive_name = this->flags()&  ~(STATE|PUSHED|HIGHLIGHT);
> Flags flags = descriptive_name | OUTPUT;
>
> Of course the difficulty is finding the right descriptive name that
> is short, readable, unambiguous, aesthetically pleasing... :-)

In _this_ case you could simply use ... "flags" ;-)

Flags flags = this->flags() & ~(STATE|PUSHED|HIGHLIGHT);
flags |= OUTPUT;

or, even more verbose:

Flags flags = this->flags();            // get current flags
flags &= ~(STATE|PUSHED|HIGHLIGHT);     // clear STATE,PUSHED,HIGHLIGHT
flags |= OUTPUT;                        // set OUTPUT

I don't think that the result after optimizing would be any slower.

Albrecht
_______________________________________________
fltk mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk

Reply via email to