Tcl Source Code

Artifact [b509ab9c7a]
Login

Artifact b509ab9c7a98cdb03e3bb73de8941eed77875abc:

Attachment "avoid-getstringfromobj.diff" to ticket [1522510fff] added by fridolin 2006-07-14 19:04:44.
*** tclExecute.c	2006-03-30 03:03:24.000000000 +0200
--- tclExecute.c.new	2006-07-14 13:55:20.000000000 +0200
***************
*** 723,763 ****
      AuxData *auxDataPtr;
      LiteralEntry *entryPtr;
      Tcl_Obj *saveObjPtr, *resultPtr;
!     char *string;
      int length, i, result;
  
      /*
-      * First handle some common expressions specially.
-      */
- 
-     string = Tcl_GetStringFromObj(objPtr, &length);
-     if (length == 1) {
- 	if (*string == '0') {
- 	    TclNewBooleanObj(resultPtr, 0);
- 	    Tcl_IncrRefCount(resultPtr);
- 	    *resultPtrPtr = resultPtr;
- 	    return TCL_OK;
- 	} else if (*string == '1') {
- 	    TclNewBooleanObj(resultPtr, 1);
- 	    Tcl_IncrRefCount(resultPtr);
- 	    *resultPtrPtr = resultPtr;
- 	    return TCL_OK;
- 	}
-     } else if ((length == 2) && (*string == '!')) {
- 	if (*(string+1) == '0') {
- 	    TclNewBooleanObj(resultPtr, 1);
- 	    Tcl_IncrRefCount(resultPtr);
- 	    *resultPtrPtr = resultPtr;
- 	    return TCL_OK;
- 	} else if (*(string+1) == '1') {
- 	    TclNewBooleanObj(resultPtr, 0);
- 	    Tcl_IncrRefCount(resultPtr);
- 	    *resultPtrPtr = resultPtr;
- 	    return TCL_OK;
- 	}
-     }
- 
-     /*
       * Get the ByteCode from the object. If it exists, make sure it hasn't
       * been invalidated by, e.g., someone redefining a command with a compile
       * procedure (this might make the compiled code wrong). If necessary,
--- 723,732 ----
      AuxData *auxDataPtr;
      LiteralEntry *entryPtr;
      Tcl_Obj *saveObjPtr, *resultPtr;
!     char *string = NULL;
      int length, i, result;
  
      /*
       * Get the ByteCode from the object. If it exists, make sure it hasn't
       * been invalidated by, e.g., someone redefining a command with a compile
       * procedure (this might make the compiled code wrong). If necessary,
***************
*** 782,789 ****
--- 751,792 ----
  		objPtr->typePtr = (Tcl_ObjType *) NULL;
  	    }
  	}
+     } else {
+     /*
+      * First handle some common expressions specially.
+      */
+ 
+         string = Tcl_GetStringFromObj(objPtr, &length);
+         if (length == 1) {
+             if (*string == '0') {
+                 TclNewBooleanObj(resultPtr, 0);
+                 Tcl_IncrRefCount(resultPtr);
+                 *resultPtrPtr = resultPtr;
+                 return TCL_OK;
+             } else if (*string == '1') {
+                 TclNewBooleanObj(resultPtr, 1);
+                 Tcl_IncrRefCount(resultPtr);
+                 *resultPtrPtr = resultPtr;
+                 return TCL_OK;
+             }
+         } else if ((length == 2) && (*string == '!')) {
+             if (*(string+1) == '0') {
+                 TclNewBooleanObj(resultPtr, 1);
+                 Tcl_IncrRefCount(resultPtr);
+                 *resultPtrPtr = resultPtr;
+                 return TCL_OK;
+             } else if (*(string+1) == '1') {
+                 TclNewBooleanObj(resultPtr, 0);
+                 Tcl_IncrRefCount(resultPtr);
+                 *resultPtrPtr = resultPtr;
+                 return TCL_OK;
+             }
+     }
+ 
+ 
      }
      if (objPtr->typePtr != &tclByteCodeType) {
+         if( string == NULL ) string = Tcl_GetStringFromObj(objPtr, &length);
  	TclInitCompileEnv(interp, &compEnv, string, length);
  	result = TclCompileExpr(interp, string, length, &compEnv);