summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMiguel Sofer <miguel.sofer@gmail.com>2004-09-10 12:48:34 (GMT)
committerMiguel Sofer <miguel.sofer@gmail.com>2004-09-10 12:48:34 (GMT)
commit7ae4115a5e7d953245963c4287ad342e9c0f54ba (patch)
tree2e5183af73491bbe7705551e34535bf3d2aaea95
parent3b09378118bfed68006ac0cb3e3dc2c5abbe04e4 (diff)
downloadtcl-7ae4115a5e7d953245963c4287ad342e9c0f54ba.zip
tcl-7ae4115a5e7d953245963c4287ad342e9c0f54ba.tar.gz
tcl-7ae4115a5e7d953245963c4287ad342e9c0f54ba.tar.bz2
* generic/tclExecute.c (INST_CONCAT1): added a peephole
optimisation for concatting an empty string. This enables replacing the idiom 'K $x [set x {}]' by '$x[set x {}]' for fastest execution.
-rw-r--r--ChangeLog7
-rw-r--r--generic/tclExecute.c16
2 files changed, 22 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index f859f54..f0fd156 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2004-09-10 Miguel Sofer <msofer@users.sf.net>
+
+ * generic/tclExecute.c (INST_CONCAT1): added a peephole
+ optimisation for concatting an empty string. This enables
+ replacing the idiom 'K $x [set x {}]' by '$x[set x {}]' for
+ fastest execution.
+
2004-09-09 David Gravereaux <davygrvy@pobox.com>
* win/tclWinConsole.c: Calls to WriteFile and WriteConsoleA
diff --git a/generic/tclExecute.c b/generic/tclExecute.c
index efbea33..39d87a0 100644
--- a/generic/tclExecute.c
+++ b/generic/tclExecute.c
@@ -11,7 +11,7 @@
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tclExecute.c,v 1.145 2004/07/11 21:56:01 msofer Exp $
+ * RCS: @(#) $Id: tclExecute.c,v 1.146 2004/09/10 12:48:36 msofer Exp $
*/
#ifdef STDC_HEADERS
@@ -1424,6 +1424,20 @@ TclExecuteByteCode(interp, codePtr)
opnd = TclGetUInt1AtPtr(pc+1);
/*
+ * Peephole optimisation for appending an empty string.
+ * This enables replacing 'K $x [set x{}]' by '$x[set x{}]'
+ * for fastest execution.
+ */
+
+ if (opnd == 2) {
+ Tcl_GetStringFromObj(*tosPtr, &length);
+ if (length == 0) {
+ /* Just drop the top item from the stack */
+ NEXT_INST_F(2, 1, 0);
+ }
+ }
+
+ /*
* Concatenate strings (with no separators) from the top
* opnd items on the stack starting with the deepest item.
* First, determine how many characters are needed.