summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--generic/tclProc.c17
1 files 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