From ba787af9328db1a9158f31d33bce5d65e357b270 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Tue, 27 Aug 2019 16:37:48 +0200 Subject: [PATCH] Replace a chain of "if"s with a "switch" in wxMSW wxListCtrl Also return false from GetSubItemRect() if an invalid code is passed in, instead of silently using wxLIST_RECT_BOUNDS instead of it. --- src/msw/listctrl.cpp | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/src/msw/listctrl.cpp b/src/msw/listctrl.cpp index 91d0985bf4..7e2512a7ad 100644 --- a/src/msw/listctrl.cpp +++ b/src/msw/listctrl.cpp @@ -1223,16 +1223,23 @@ bool wxListCtrl::GetSubItemRect(long item, long subItem, wxRect& rect, int code) wxT("invalid item in GetSubItemRect") ); int codeWin; - if ( code == wxLIST_RECT_BOUNDS ) - codeWin = LVIR_BOUNDS; - else if ( code == wxLIST_RECT_ICON ) - codeWin = LVIR_ICON; - else if ( code == wxLIST_RECT_LABEL ) - codeWin = LVIR_LABEL; - else + switch ( code ) { - wxFAIL_MSG( wxT("incorrect code in GetItemRect() / GetSubItemRect()") ); - codeWin = LVIR_BOUNDS; + case wxLIST_RECT_BOUNDS: + codeWin = LVIR_BOUNDS; + break; + + case wxLIST_RECT_ICON: + codeWin = LVIR_ICON; + break; + + case wxLIST_RECT_LABEL: + codeWin = LVIR_LABEL; + break; + + default: + wxFAIL_MSG( wxT("incorrect code in GetItemRect() / GetSubItemRect()") ); + return false; } RECT rectWin;