[PATCH 4/4] comctl32/treeview: Get rid of useless float cast

Gabriel Ivăncescu gabrielopcode at gmail.com
Tue Aug 21 15:33:11 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/comctl32/treeview.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/dlls/comctl32/treeview.c b/dlls/comctl32/treeview.c
index bbef651..8a34d6c 100644
--- a/dlls/comctl32/treeview.c
+++ b/dlls/comctl32/treeview.c
@@ -5030,7 +5030,7 @@ scroll:
 static LRESULT
 TREEVIEW_MouseWheel(TREEVIEW_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
 {
-    short wheelDelta;
+    SHORT wheelDelta;
     UINT pulScrollLines = 3;
 
     if (wParam & (MK_SHIFT | MK_CONTROL))
@@ -5051,12 +5051,12 @@ TREEVIEW_MouseWheel(TREEVIEW_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
 
     if (infoPtr->wheelRemainder && pulScrollLines)
     {
-	int newDy;
-	int maxDy;
-	int lineScroll;
+	INT newDy;
+	INT maxDy;
+	INT lineScroll;
 
-	lineScroll = pulScrollLines * (float)infoPtr->wheelRemainder / WHEEL_DELTA;
-	infoPtr->wheelRemainder -= WHEEL_DELTA * lineScroll / (int)pulScrollLines;
+	lineScroll = ((INT)pulScrollLines * infoPtr->wheelRemainder) / WHEEL_DELTA;
+	infoPtr->wheelRemainder -= (lineScroll * WHEEL_DELTA) / (INT)pulScrollLines;
 
 	newDy = infoPtr->firstVisible->visibleOrder - lineScroll;
 	maxDy = infoPtr->maxVisibleOrder;
-- 
1.9.1




More information about the wine-devel mailing list