Subject: Generate better code for the common case of subst-ed variables where the variable is a simple scalar or an array with a simple literal element name.

From: dkf <[email-masked]>
Date: Tue, 18 Dec 2012 09:37:42 +0000

---
 generic/tclCompCmdsSZ.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/generic/tclCompCmdsSZ.c b/generic/tclCompCmdsSZ.c
index 9c93fb2..71a1dfc 100644
--- a/generic/tclCompCmdsSZ.c
+++ b/generic/tclCompCmdsSZ.c
@@ -836,6 +836,21 @@ TclSubstCompile(
 	    TclEmitPush(literal, envPtr);
 	    count++;
 	    continue;
+	case TCL_TOKEN_VARIABLE:
+	    /*
+	     * Simple variable access; can only generate TCL_OK or TCL_ERROR
+	     * so no need to generate elaborate exception-management code.
+	     */
+
+	    if (tokenPtr->numComponents == 1 || (tokenPtr->numComponents == 2
+		    && tokenPtr[2].type == TCL_TOKEN_TEXT)) {
+		envPtr->line = bline;
+		TclCompileVarSubst(interp, tokenPtr, envPtr);
+		bline = envPtr->line;
+		count++;
+		continue;
+	    }
+	    break;
 	}
 
 	while (count > 255) {
-- 
cgit v0.12