Compare commits

...
3 Commits
4 changed files with 56 additions and 4 deletions
+8
View File
@@ -6042,6 +6042,14 @@ TclNREvalObjEx(
Interp *iPtr = (Interp *) interp;
int result;
/*
* Shortcut for empty scripts; avoid computing a string rep
*/
if (objPtr->bytes && (*objPtr->bytes == '\0')) {
return TCL_OK;
}
/*
* This function consists of three independent blocks for: direct
* evaluation of canonical lists, compilation and bytecode execution and
+8 -2
View File
@@ -1250,8 +1250,14 @@ Tcl_NRSubstObj(
{
ByteCode *codePtr = CompileSubstObj(interp, objPtr, flags);
/* TODO: Confirm we do not need this. */
/* Tcl_ResetResult(interp); */
/*
* Shortcut for empty scripts; avoid computing a string rep
*/
if (objPtr->bytes && (*objPtr->bytes == '\0')) {
return TCL_OK;
}
return TclNRExecuteByteCode(interp, codePtr);
}
+9
View File
@@ -2030,6 +2030,15 @@ TclNRExecuteByteCode(
* sizeof(void *);
int numWords = (size + sizeof(Tcl_Obj *) - 1) / sizeof(Tcl_Obj *);
/*
* Shortcut for compiled empty scripts
*/
if (codePtr->source && (*codePtr->source == '\0')
&& !(codePtr->flags & TCL_BYTECODE_PRECOMPILED)) {
return TCL_OK;
}
codePtr->refCount++;
/*
+31 -2
View File
@@ -1375,7 +1375,7 @@ InitArgsAndLocals(
if (localCt) {
if (!codePtr->localCachePtr) {
InitLocalCache(procPtr) ;
InitLocalCache(procPtr);
}
framePtr->localCachePtr = codePtr->localCachePtr;
framePtr->localCachePtr->refCount++;
@@ -1635,12 +1635,41 @@ TclNRInterpProc(
* procedure. */
Tcl_Obj *const objv[]) /* Argument value objects. */
{
int result = TclPushProcCallFrame(clientData, interp, objc, objv,
Proc *procPtr = clientData;
Interp *iPtr = (Interp *) interp;
int result;
Tcl_Obj *bodyPtr = procPtr->bodyPtr;
/*
* Shortcut for empty bodies. Note that this also avoids compiling and
* shimmering the empty string, as well as pushing/popping a CallFrame and
* invoking TEBC.
*/
if (bodyPtr->bytes && (*bodyPtr->bytes == '\0')) {
/* empty body ... */
ByteCode *codePtr = (ByteCode *) bodyPtr->internalRep.twoPtrValue.ptr1;
if ((bodyPtr->typePtr != &tclByteCodeType) ||
!(codePtr->flags & TCL_BYTECODE_PRECOMPILED)) {
/* ... and not precompiled ... */
if (objc == procPtr->numArgs + 1) {
/* ... and correct number of arguments; we will still be
* compiling empty bodies that have default values or args
* for simplicity sake - to avoid having to go through the
* linked list of compiled locals to determine the nature of
* the last formal argument(s). */
return TCL_OK;
}
}
}
result = TclPushProcCallFrame(procPtr, interp, objc, objv,
/*isLambda*/ 0);
if (result != TCL_OK) {
return TCL_ERROR;
}
return TclNRInterpProcCore(interp, objv[0], 1, &MakeProcError);
}