[PATCH 2/4] user32/edit: Get rid of useless float cast

Gabriel Ivăncescu gabrielopcode at gmail.com
Tue Aug 21 15:33:09 CDT 2018


Since the division (the only operation with a fractional result) was
immediately truncated to integer anyway, the float cast is completely
useless. This works fine because the multiplication is done before the
division (parentheses have been added to emphasize this point).

Signed-off-by: Gabriel Ivăncescu <gabrielopcode at gmail.com>
---
 dlls/user32/edit.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/dlls/user32/edit.c b/dlls/user32/edit.c
index 96ecbec..6758344 100644
--- a/dlls/user32/edit.c
+++ b/dlls/user32/edit.c
@@ -5103,7 +5103,7 @@ LRESULT EditWndProc_common( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam, B
 
         case WM_MOUSEWHEEL:
                 {
-                    int wheelDelta;
+                    INT wheelDelta;
                     UINT pulScrollLines = 3;
                     SystemParametersInfoW(SPI_GETWHEELSCROLLLINES,0, &pulScrollLines, 0);
 
@@ -5120,10 +5120,10 @@ LRESULT EditWndProc_common( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam, B
                         es->wheelDeltaRemainder = wheelDelta;
                     if (es->wheelDeltaRemainder && pulScrollLines)
                     {
-                        int cLineScroll;
-                        pulScrollLines = (int) min((UINT) es->line_count, pulScrollLines);
-                        cLineScroll = pulScrollLines * (float)es->wheelDeltaRemainder / WHEEL_DELTA;
-                        es->wheelDeltaRemainder -= WHEEL_DELTA * cLineScroll / (int)pulScrollLines;
+                        INT cLineScroll;
+                        pulScrollLines = (INT) min((UINT) es->line_count, pulScrollLines);
+                        cLineScroll = ((INT)pulScrollLines * es->wheelDeltaRemainder) / WHEEL_DELTA;
+                        es->wheelDeltaRemainder -= (cLineScroll * WHEEL_DELTA) / (INT)pulScrollLines;
                         result = EDIT_EM_LineScroll(es, 0, -cLineScroll);
                     }
                 }
-- 
1.9.1




More information about the wine-devel mailing list