summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordkf <donal.k.fellows@manchester.ac.uk>2005-11-29 14:02:02 (GMT)
committerdkf <donal.k.fellows@manchester.ac.uk>2005-11-29 14:02:02 (GMT)
commit78e4bd756c392b75621c7d8c46d00a7cc2c03701 (patch)
tree1128e6e95a2bb6e12506385bd371e00436ad8a4f
parentd8635a48cf1f669a2c8103dacc8a93e3e3269b87 (diff)
downloadtcl-78e4bd756c392b75621c7d8c46d00a7cc2c03701.zip
tcl-78e4bd756c392b75621c7d8c46d00a7cc2c03701.tar.gz
tcl-78e4bd756c392b75621c7d8c46d00a7cc2c03701.tar.bz2
Fix [Bug 1310081].
-rw-r--r--ChangeLog3
-rw-r--r--generic/tclObj.c13
2 files changed, 15 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index 0e98fdc..f59f68e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,8 @@
2005-11-29 Donal K. Fellows <donal.k.fellows@man.ac.uk>
+ * generic/tclObj.c (Tcl_GetWideIntFromObj): Add more efficient
+ conversion to wides from normal ints. [Bug 1310081]
+
* generic/tclCmdIL.c (Tcl_LsearchObjCmd): Allow [lsearch -regexp] to
process REs that contain backreferences. This expensive mode of
operation is only used if the RE would otherwise cause a compilation
diff --git a/generic/tclObj.c b/generic/tclObj.c
index 7ae0b5e..9d480d5 100644
--- a/generic/tclObj.c
+++ b/generic/tclObj.c
@@ -11,7 +11,7 @@
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tclObj.c,v 1.42.2.13 2005/08/04 19:54:29 dgp Exp $
+ * RCS: @(#) $Id: tclObj.c,v 1.42.2.14 2005/11/29 14:02:04 dkf Exp $
*/
#include "tclInt.h"
@@ -2574,9 +2574,20 @@ Tcl_GetWideIntFromObj(interp, objPtr, wideIntPtr)
register int result;
if (objPtr->typePtr == &tclWideIntType) {
+ gotWide:
*wideIntPtr = objPtr->internalRep.wideValue;
return TCL_OK;
}
+ if (objPtr->typePtr == &tclIntType) {
+ /*
+ * This cast is safe; all valid ints/longs are wides.
+ */
+
+ objPtr->internalRep.wideValue =
+ Tcl_LongAsWide(objPtr->internalRep.longValue);
+ objPtr->typePtr = &tclWideIntType;
+ goto gotWide;
+ }
result = SetWideIntFromAny(interp, objPtr);
if (result == TCL_OK) {
*wideIntPtr = objPtr->internalRep.wideValue;