From 35d9b0f056de428d0c83846b209738463fa62372 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Fri, 27 Sep 2019 19:29:42 +0200 Subject: [PATCH] Rewrite a chain of "if"s as a switch No real changes, just make the code a bit more maintainable and easier to read. --- src/common/intl.cpp | 45 +++++++++++++++++++++------------------------ 1 file changed, 21 insertions(+), 24 deletions(-) diff --git a/src/common/intl.cpp b/src/common/intl.cpp index 96dd2389d6..6d4d200c95 100644 --- a/src/common/intl.cpp +++ b/src/common/intl.cpp @@ -877,37 +877,34 @@ wxString wxLocale::GetSystemEncodingName() wxFontEncoding wxLocale::GetSystemEncoding() { #if defined(__WIN32__) - UINT codepage = ::GetACP(); + const UINT codepage = ::GetACP(); - // wxWidgets only knows about CP1250-1257, 874, 932, 936, 949, 950 - if ( codepage >= 1250 && codepage <= 1257 ) + switch ( codepage ) { - return (wxFontEncoding)(wxFONTENCODING_CP1250 + codepage - 1250); - } + case 1250: + case 1251: + case 1252: + case 1253: + case 1254: + case 1255: + case 1256: + case 1257: + return (wxFontEncoding)(wxFONTENCODING_CP1250 + codepage - 1250); - if ( codepage == 874 ) - { - return wxFONTENCODING_CP874; - } + case 874: + return wxFONTENCODING_CP874; - if ( codepage == 932 ) - { - return wxFONTENCODING_CP932; - } + case 932: + return wxFONTENCODING_CP932; - if ( codepage == 936 ) - { - return wxFONTENCODING_CP936; - } + case 936: + return wxFONTENCODING_CP936; - if ( codepage == 949 ) - { - return wxFONTENCODING_CP949; - } + case 949: + return wxFONTENCODING_CP949; - if ( codepage == 950 ) - { - return wxFONTENCODING_CP950; + case 950: + return wxFONTENCODING_CP950; } #elif defined(__WXMAC__) CFStringEncoding encoding = 0 ;