From 3ef067f6d11a67a440bdf15b47191b87b9e1daef Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 20 Apr 2015 16:52:48 -0400 Subject: [PATCH] optimized hex digit verification a little --- Source/Project64/N64 System/Cheat Class.cpp | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/Source/Project64/N64 System/Cheat Class.cpp b/Source/Project64/N64 System/Cheat Class.cpp index efa97355a..897ca66ce 100644 --- a/Source/Project64/N64 System/Cheat Class.cpp +++ b/Source/Project64/N64 System/Cheat Class.cpp @@ -1917,11 +1917,15 @@ stdstr CCheats::ReadOptionsString(HWND hDlg, bool &/*validcodes*/, bool &validop int is_valid_hex_digit(char symbol) { - if ( - ((symbol >= 'a') && (symbol <= 'f')) - || ((symbol >= 'A') && (symbol <= 'F')) - || ((symbol >= '0') && (symbol <= '9')) - ) + if (symbol < '0') + return 0; /* no valid hex figures before '0' */ + if (symbol <= '9') + return 1; + + symbol &= ~0x20; /* in ASCII, forces lowercase to uppercase */ + if (symbol < 'A') + return 0; + if (symbol <= 'Z') return 1; return 0; }