On Wed, 20 Oct 2004 19:48:05 +0900, you wrote: > Hello, > > Changelog: > Dmitry Timoshkov <[EMAIL PROTECTED]> > Tiny optimizations of bit testing operations.
Testing with gcc 3.3.5: > - BOOL min_or_max_box = (wndPtr->dwStyle & WS_MAXIMIZEBOX) || > - (wndPtr->dwStyle & WS_MINIMIZEBOX); > + BOOL min_or_max_box = wndPtr->dwStyle & (WS_MAXIMIZEBOX | > WS_MINIMIZEBOX); At moderate optimization levels (-O1) gcc compiles this to identical code. > - if((wndPtr->dwExStyle & WS_EX_LEFTSCROLLBAR) != 0) > + if (wndPtr->dwExStyle & WS_EX_LEFTSCROLLBAR) At any optimization level, gcc compiles this to identical code. > if ((wndPtr->dwStyle & WS_VSCROLL) && > - ((((wndPtr->dwExStyle & WS_EX_LEFTSCROLLBAR) != 0) && (ptClient.x > <= rcClient.left + GetSystemMetrics(SM_CXVSCROLL))) || > - (((wndPtr->dwExStyle & WS_EX_LEFTSCROLLBAR) == 0) && (ptClient.x >= > rcClient.right - GetSystemMetrics(SM_CXVSCROLL))))) > + (((wndPtr->dwExStyle & WS_EX_LEFTSCROLLBAR) && (ptClient.x <= > rcClient.left + GetSystemMetrics(SM_CXVSCROLL))) || > + (!(wndPtr->dwExStyle & WS_EX_LEFTSCROLLBAR) && (ptClient.x >= > rcClient.right - GetSystemMetrics(SM_CXVSCROLL))))) Not different then the previous example. >From the C point of view these bit logics are identical. The compiler finds that out easy. Rein. -- Rein Klazes [EMAIL PROTECTED]