From fa6729be12fe55ffb70a5614fa32733085a7c539 Mon Sep 17 00:00:00 2001 From: escoffon Date: Wed, 10 Jun 1998 12:34:22 +0000 Subject: turn off check for shared source string in Tcl_ProcObjCmd if the body is a PRECOMPILED ByteCode object. --- generic/tclProc.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/generic/tclProc.c b/generic/tclProc.c index c9039df..273f12f 100644 --- a/generic/tclProc.c +++ b/generic/tclProc.c @@ -112,13 +112,26 @@ Tcl_ProcObjCmd(dummy, interp, objc, objv) * procedures that have a different number of arguments, even if their * bodies are identical. Note that we don't use Tcl_DuplicateObj since * we would not want any bytecode internal representation. + * + * But if this is a precompiled bytecode object, then do not duplicate it; + * precompiled bytecodes are immutable, and there is no source to + * recompile anyway. */ bodyPtr = objv[3]; if (Tcl_IsShared(bodyPtr)) { - bytes = Tcl_GetStringFromObj(bodyPtr, &length); - bodyPtr = Tcl_NewStringObj(bytes, length); + if (bodyPtr->typePtr == &tclByteCodeType) { + ByteCode *codePtr + = (ByteCode *) bodyPtr->internalRep.otherValuePtr; + if (codePtr->flags & TCL_BYTECODE_PRECOMPILED) { + goto skip_unshare; + } + } + + bytes = Tcl_GetStringFromObj(bodyPtr, &length); + bodyPtr = Tcl_NewStringObj(bytes, length); } + skip_unshare: /* * Create and initialize a Proc structure for the procedure. Note that -- cgit v0.12