diff options
author | dgp <dgp@users.sourceforge.net> | 2016-10-28 14:45:54 (GMT) |
---|---|---|
committer | dgp <dgp@users.sourceforge.net> | 2016-10-28 14:45:54 (GMT) |
commit | 335716b81d99c7476e68979fe48b20b0f2bfeeee (patch) | |
tree | a08e364e1ff2d0f435cca83bd3a9d4e100f35a5d /generic/tclCmdIL.c | |
parent | a81f6b904b3b6777ed2da4e55b669b7e4770dcc9 (diff) | |
download | tcl-335716b81d99c7476e68979fe48b20b0f2bfeeee.zip tcl-335716b81d99c7476e68979fe48b20b0f2bfeeee.tar.gz tcl-335716b81d99c7476e68979fe48b20b0f2bfeeee.tar.bz2 |
Add obvious optimizations to [join] implementation.
Diffstat (limited to 'generic/tclCmdIL.c')
-rw-r--r-- | generic/tclCmdIL.c | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/generic/tclCmdIL.c b/generic/tclCmdIL.c index bb3c9b7..7f4ca1d 100644 --- a/generic/tclCmdIL.c +++ b/generic/tclCmdIL.c @@ -2173,6 +2173,16 @@ Tcl_JoinObjCmd( return TCL_ERROR; } + if (listLen == 0) { + /* No elements to join; default empty result is correct. */ + return TCL_OK; + } + if (listLen == 1) { + /* One element; return it */ + Tcl_SetObjResult(interp, elemPtrs[0]); + return TCL_OK; + } + joinObjPtr = (objc == 2) ? Tcl_NewStringObj(" ", 1) : objv[2]; Tcl_IncrRefCount(joinObjPtr); |