diff options
author | sebres <sebres@users.sourceforge.net> | 2017-05-31 08:24:42 (GMT) |
---|---|---|
committer | sebres <sebres@users.sourceforge.net> | 2017-05-31 08:24:42 (GMT) |
commit | cef09a18ae9b1a55404db45ade312b06880c0f65 (patch) | |
tree | e73fc19ec24f5279ef4b87e4b930b0113a167ea4 | |
parent | a0b8a82e5511a9503eaa1fc5174be0e652e0fe6d (diff) | |
download | tcl-cef09a18ae9b1a55404db45ade312b06880c0f65.zip tcl-cef09a18ae9b1a55404db45ade312b06880c0f65.tar.gz tcl-cef09a18ae9b1a55404db45ade312b06880c0f65.tar.bz2 |
performance of INST_STR_CONCAT1: closes [716b427f76f8f97a8d9a06043903c53bb2b592c2]: minor optimization in simplest cases,
fixed performance regression of TclStringCatObjv usage from [fc9ed1e751180816384d569101950c1f8c4582ad],
optimizes patterns like "$v[unset v]", "$v[set v {}]" etc.
-rw-r--r-- | generic/tclExecute.c | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/generic/tclExecute.c b/generic/tclExecute.c index cfcdd26..2d1c07f 100644 --- a/generic/tclExecute.c +++ b/generic/tclExecute.c @@ -2685,11 +2685,34 @@ TEBCresume( opnd = TclGetUInt1AtPtr(pc+1); + objv = &OBJ_AT_DEPTH(opnd-1); + /* minor optimization in simplest cases */ + switch (opnd) { + case 1: /* only one object */ + objResultPtr = *objv; + goto endINST_STR_CONCAT1; + case 2: /* two objects - check empty */ + if (objv[0]->bytes == &tclEmptyString) { + objResultPtr = objv[1]; + goto endINST_STR_CONCAT1; + } + else + if (objv[1]->bytes == &tclEmptyString) { + objResultPtr = objv[0]; + goto endINST_STR_CONCAT1; + } + break; + case 0: /* no objects - use new empty */ + TclNewObj(objResultPtr); + goto endINST_STR_CONCAT1; + } + /* do concat */ if (TCL_OK != TclStringCatObjv(interp, /* inPlace */ 1, - opnd, &OBJ_AT_DEPTH(opnd-1), &objResultPtr)) { + opnd, objv, &objResultPtr)) { TRACE_ERROR(interp); goto gotError; } + endINST_STR_CONCAT1: TRACE_WITH_OBJ(("%u => ", opnd), objResultPtr); NEXT_INST_V(2, opnd, 1); |