From ec6eb4ba32bf8009102b28f1e4c0d86dc133c5b2 Mon Sep 17 00:00:00 2001 From: Zufu Liu Date: Wed, 29 Sep 2021 14:04:04 +1000 Subject: Feature [feature-requests:#1416] Shorten code and avoid cppcheck warning. --- win32/PlatWin.cxx | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) (limited to 'win32') diff --git a/win32/PlatWin.cxx b/win32/PlatWin.cxx index c4f08b798..9035aa6f2 100644 --- a/win32/PlatWin.cxx +++ b/win32/PlatWin.cxx @@ -3714,13 +3714,7 @@ LRESULT ListBoxX::WndProc(HWND hWnd, UINT iMessage, WPARAM wParam, LPARAM lParam wheelDelta -= GET_WHEEL_DELTA_WPARAM(wParam); if (std::abs(wheelDelta) >= WHEEL_DELTA) { const int nRows = GetVisibleRows(); - int linesToScroll = 1; - if (nRows > 1) { - linesToScroll = nRows - 1; - } - if (linesToScroll > 3) { - linesToScroll = 3; - } + int linesToScroll = std::clamp(nRows - 1, 1, 3); linesToScroll *= (wheelDelta / WHEEL_DELTA); int top = ListBox_GetTopIndex(lb) + linesToScroll; if (top < 0) { -- cgit v1.2.3