diff options
author | Steve Bennett <steveb@workware.net.au> | 2017-05-16 13:15:41 +1000 |
---|---|---|
committer | Steve Bennett <steveb@workware.net.au> | 2017-05-23 14:36:49 +1000 |
commit | 7b2250a7e60968b0c3716a7caa780e6ca0a2ce9b (patch) | |
tree | 0668000aec793fbb6a1f5123b167672122851306 | |
parent | 9718405db885bf6ff6ab6b9833aee7b5a06d915b (diff) | |
download | jimtcl-7b2250a7e60968b0c3716a7caa780e6ca0a2ce9b.zip jimtcl-7b2250a7e60968b0c3716a7caa780e6ca0a2ce9b.tar.gz jimtcl-7b2250a7e60968b0c3716a7caa780e6ca0a2ce9b.tar.bz2 |
optimisation: when converting to double, may not need stringrep
Minor optimisation
Signed-off-by: Steve Bennett <steveb@workware.net.au>
-rw-r--r-- | jim.c | 11 |
1 files changed, 5 insertions, 6 deletions
@@ -6013,11 +6013,6 @@ static int SetDoubleFromAny(Jim_Interp *interp, Jim_Obj *objPtr) jim_wide wideValue; const char *str; - /* Preserve the string representation. - * Needed so we can convert back to int without loss - */ - str = Jim_String(objPtr); - #ifdef HAVE_LONG_LONG /* Assume a 53 bit mantissa */ #define MIN_INT_IN_DOUBLE -(1LL << 53) @@ -6031,8 +6026,12 @@ static int SetDoubleFromAny(Jim_Interp *interp, Jim_Obj *objPtr) objPtr->typePtr = &coercedDoubleObjType; return JIM_OK; } - else #endif + /* Preserve the string representation. + * Needed so we can convert back to int without loss + */ + str = Jim_String(objPtr); + if (Jim_StringToWide(str, &wideValue, 10) == JIM_OK) { /* Managed to convert to an int, so we can use this as a cooerced double */ Jim_FreeIntRep(interp, objPtr); |