aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSteve Bennett <steveb@workware.net.au>2017-05-16 13:15:41 +1000
committerSteve Bennett <steveb@workware.net.au>2017-05-23 14:36:49 +1000
commit7b2250a7e60968b0c3716a7caa780e6ca0a2ce9b (patch)
tree0668000aec793fbb6a1f5123b167672122851306
parent9718405db885bf6ff6ab6b9833aee7b5a06d915b (diff)
downloadjimtcl-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.c11
1 files changed, 5 insertions, 6 deletions
diff --git a/jim.c b/jim.c
index 18217b7..9e2bb81 100644
--- a/jim.c
+++ b/jim.c
@@ -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);