diff options
| author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2014-11-04 17:16:25 -0200 |
|---|---|---|
| committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2014-11-04 17:16:25 -0200 |
| commit | 81c39a5244a64f00a3e1647cc760454eeb56bae0 (patch) | |
| tree | b596faaeb2f9f531c9a351f025641a1b2dd85299 | |
| parent | cfabcbfb1785a64352b384e16e0477e2b47cee22 (diff) | |
| download | lua-81c39a5244a64f00a3e1647cc760454eeb56bae0.tar.gz lua-81c39a5244a64f00a3e1647cc760454eeb56bae0.tar.bz2 lua-81c39a5244a64f00a3e1647cc760454eeb56bae0.zip | |
no need to cast '*s' to unsigned char when we know it is a digit +
no need to call 'luaO_hexavalue' for decimal digits
| -rw-r--r-- | lobject.c | 8 |
1 files changed, 4 insertions, 4 deletions
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: lobject.c,v 2.97 2014/10/28 18:41:38 roberto Exp roberto $ | 2 | ** $Id: lobject.c,v 2.98 2014/11/02 19:19:04 roberto Exp roberto $ |
| 3 | ** Some generic functions over Lua objects | 3 | ** Some generic functions over Lua objects |
| 4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
| 5 | */ | 5 | */ |
| @@ -204,7 +204,7 @@ static lua_Number lua_strx2number (const char *s, char **endptr) { | |||
| 204 | if (sigdig == 0 && *s == '0') /* non-significant digit (zero)? */ | 204 | if (sigdig == 0 && *s == '0') /* non-significant digit (zero)? */ |
| 205 | nosigdig++; | 205 | nosigdig++; |
| 206 | else if (++sigdig <= MAXSIGDIG) /* can read it without overflow? */ | 206 | else if (++sigdig <= MAXSIGDIG) /* can read it without overflow? */ |
| 207 | r = (r * cast_num(16.0)) + luaO_hexavalue(cast_uchar(*s)); | 207 | r = (r * cast_num(16.0)) + luaO_hexavalue(*s); |
| 208 | else e++; /* too many digits; ignore, but still count for exponent */ | 208 | else e++; /* too many digits; ignore, but still count for exponent */ |
| 209 | if (dot) e--; /* decimal digit? correct exponent */ | 209 | if (dot) e--; /* decimal digit? correct exponent */ |
| 210 | } | 210 | } |
| @@ -259,13 +259,13 @@ static const char *l_str2int (const char *s, lua_Integer *result) { | |||
| 259 | (s[1] == 'x' || s[1] == 'X')) { /* hex? */ | 259 | (s[1] == 'x' || s[1] == 'X')) { /* hex? */ |
| 260 | s += 2; /* skip '0x' */ | 260 | s += 2; /* skip '0x' */ |
| 261 | for (; lisxdigit(cast_uchar(*s)); s++) { | 261 | for (; lisxdigit(cast_uchar(*s)); s++) { |
| 262 | a = a * 16 + luaO_hexavalue(cast_uchar(*s)); | 262 | a = a * 16 + luaO_hexavalue(*s); |
| 263 | empty = 0; | 263 | empty = 0; |
| 264 | } | 264 | } |
| 265 | } | 265 | } |
| 266 | else { /* decimal */ | 266 | else { /* decimal */ |
| 267 | for (; lisdigit(cast_uchar(*s)); s++) { | 267 | for (; lisdigit(cast_uchar(*s)); s++) { |
| 268 | a = a * 10 + luaO_hexavalue(cast_uchar(*s)); | 268 | a = a * 10 + *s - '0'; |
| 269 | empty = 0; | 269 | empty = 0; |
| 270 | } | 270 | } |
| 271 | } | 271 | } |
