diff options
author | msofer <msofer@noemail.net> | 2004-09-10 15:30:01 (GMT) |
---|---|---|
committer | msofer <msofer@noemail.net> | 2004-09-10 15:30:01 (GMT) |
commit | 51a39f023a92bd534cf82c51c0b2c1514b3143f8 (patch) | |
tree | 269aa3736a882e762fde8fc0e6cd871aafbc041b /generic/tclExecute.c | |
parent | 14da1fbf33b5e1d8b86a3971434d655d27ac0b9b (diff) | |
download | tcl-51a39f023a92bd534cf82c51c0b2c1514b3143f8.zip tcl-51a39f023a92bd534cf82c51c0b2c1514b3143f8.tar.gz tcl-51a39f023a92bd534cf82c51c0b2c1514b3143f8.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.
FossilOrigin-Name: 4caa0c8b729d81f5a4777d9b8ec05f3f59d02401
Diffstat (limited to 'generic/tclExecute.c')
-rw-r--r-- | generic/tclExecute.c | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/generic/tclExecute.c b/generic/tclExecute.c index 79b03b9..b0a94fe 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.94.2.7 2004/07/03 22:13:10 msofer Exp $ + * RCS: @(#) $Id: tclExecute.c,v 1.94.2.8 2004/09/10 15:30:02 msofer Exp $ */ #include "tclInt.h" @@ -1264,6 +1264,20 @@ TclExecuteByteCode(interp, codePtr) int totalLen = 0; /* + * 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(stackPtr[stackTop], &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. |