On Wed, 20 Oct 2004 19:48:05 +0900, you wrote:
Hello,
Changelog: Dmitry Timoshkov dmitry@codeweavers.com 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" rklazes@xs4all.nl wrote:
From the C point of view these bit logics are identical. The compiler finds that out easy.
Yes, I know. That's why the optimizations are "tiny". I believe that the code itself becomes more readable with my changes and makes it not depend on the optimizations a compiler is capable to perform.
On Wed, 20 Oct 2004 22:29:35 +0900, you wrote:
From the C point of view these bit logics are identical. The compiler finds that out easy.
Yes, I know. That's why the optimizations are "tiny". I believe that the code itself becomes more readable with my changes and makes it not depend on the optimizations a compiler is capable to perform.
I think even "tiny" is an exaggeration. Gcc has been capable of doing this for years and years. I'd be surprised if you could find a compiler that could not, and still compile wine satisfactory.
Rein.
On Wed, Oct 20, 2004 at 04:13:07PM +0200, Rein Klazes wrote:
On Wed, 20 Oct 2004 22:29:35 +0900, you wrote:
From the C point of view these bit logics are identical. The compiler finds that out easy.
Yes, I know. That's why the optimizations are "tiny". I believe that the code itself becomes more readable with my changes and makes it not depend on the optimizations a compiler is capable to perform.
I think even "tiny" is an exaggeration. Gcc has been capable of doing this for years and years. I'd be surprised if you could find a compiler that could not, and still compile wine satisfactory.
I guess such changes are acceptable if it makes the sourcecode more readable.
Ciao, Marcus
Marcus Meissner meissner@suse.de writes:
I think even "tiny" is an exaggeration. Gcc has been capable of doing this for years and years. I'd be surprised if you could find a compiler that could not, and still compile wine satisfactory.
I guess such changes are acceptable if it makes the sourcecode more readable.
Here it's not clear at all that one is more readable than the other; and in such a case the policy is that whoever writes the code in the first place gets to decide how it's done.