From 589f7e0a57675efce9810c15a3e9b7c49bf0bc90 Mon Sep 17 00:00:00 2001 From: Dan Sinclair Date: Thu, 29 Oct 2015 14:56:26 -0400 Subject: Cleanup some numeric code. This changes the various comparisons of char >= '0' && char <= '9' and char < '0' || char > '9' to use std::isdigit checks. It also cleans up a handful of hex to digit conversions to call one common method. R=thestig@chromium.org Review URL: https://codereview.chromium.org/1415933005 . --- core/src/fxcrt/fx_basic_gcc.cpp | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'core/src/fxcrt/fx_basic_gcc.cpp') diff --git a/core/src/fxcrt/fx_basic_gcc.cpp b/core/src/fxcrt/fx_basic_gcc.cpp index 6f17482156..71f5fe322f 100644 --- a/core/src/fxcrt/fx_basic_gcc.cpp +++ b/core/src/fxcrt/fx_basic_gcc.cpp @@ -12,21 +12,20 @@ template T FXSYS_StrToInt(STR_T str) { FX_BOOL neg = FALSE; - if (str == NULL) { + if (!str) return 0; - } + if (*str == '-') { neg = TRUE; str++; } T num = 0; while (*str) { - if ((*str) < '0' || (*str) > '9') { + if (!std::isdigit(*str)) break; - } - if (num > (std::numeric_limits::max() - 9) / 10) { + if (num > (std::numeric_limits::max() - 9) / 10) break; - } + num = num * 10 + (*str) - '0'; str++; } -- cgit v1.2.3