summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordgp <dgp@users.sourceforge.net>2007-03-01 22:45:45 (GMT)
committerdgp <dgp@users.sourceforge.net>2007-03-01 22:45:45 (GMT)
commit57b319287e05948bc3a93c9517e50e42b59e9f44 (patch)
tree486328923ebbefd7b22b1ae37cc3f0e809ee568e
parent96d1d0f2dd821c789b8178f9e23d7afef194aa35 (diff)
downloadtcl-57b319287e05948bc3a93c9517e50e42b59e9f44.zip
tcl-57b319287e05948bc3a93c9517e50e42b59e9f44.tar.gz
tcl-57b319287e05948bc3a93c9517e50e42b59e9f44.tar.bz2
* generic/tclCmdIL.c (Tcl_LinsertObjCmd): Code simplifications
and optimizations.
-rw-r--r--ChangeLog3
-rw-r--r--generic/tclCmdIL.c21
2 files changed, 9 insertions, 15 deletions
diff --git a/ChangeLog b/ChangeLog
index 07e8268..a1ff2e7 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,8 @@
2007-03-01 Don Porter <dgp@users.sourceforge.net>
+ * generic/tclCmdIL.c (Tcl_LinsertObjCmd): Code simplifications
+ and optimizations.
+
* generic/tclCmdIL.c (Tcl_LreplaceObjCmd): Code simplifications
and optimizations.
diff --git a/generic/tclCmdIL.c b/generic/tclCmdIL.c
index 770d990..b3c2c2f 100644
--- a/generic/tclCmdIL.c
+++ b/generic/tclCmdIL.c
@@ -16,7 +16,7 @@
* See the file "license.terms" for information on usage and redistribution of
* this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tclCmdIL.c,v 1.101 2007/03/01 22:14:19 dgp Exp $
+ * RCS: @(#) $Id: tclCmdIL.c,v 1.102 2007/03/01 22:45:46 dgp Exp $
*/
#include "tclInt.h"
@@ -2937,7 +2937,7 @@ Tcl_LinsertObjCmd(
Tcl_Obj *CONST objv[]) /* Argument objects. */
{
Tcl_Obj *listPtr;
- int index, isDuplicate, len, result;
+ int index, len, result;
if (objc < 4) {
Tcl_WrongNumArgs(interp, 1, objv, "list index element ?element ...?");
@@ -2969,10 +2969,8 @@ Tcl_LinsertObjCmd(
*/
listPtr = objv[1];
- isDuplicate = 0;
if (Tcl_IsShared(listPtr)) {
- listPtr = Tcl_DuplicateObj(listPtr);
- isDuplicate = 1;
+ listPtr = TclListObjCopy(NULL, listPtr);
}
if ((objc == 4) && (index == len)) {
@@ -2980,16 +2978,9 @@ Tcl_LinsertObjCmd(
* Special case: insert one element at the end of the list.
*/
- result = Tcl_ListObjAppendElement(interp, listPtr, objv[3]);
- } else if (objc > 3) {
- result = Tcl_ListObjReplace(interp, listPtr, index, 0,
- (objc-3), &(objv[3]));
- }
- if (result != TCL_OK) {
- if (isDuplicate) {
- Tcl_DecrRefCount(listPtr); /* free unneeded obj */
- }
- return result;
+ Tcl_ListObjAppendElement(NULL, listPtr, objv[3]);
+ } else {
+ Tcl_ListObjReplace(NULL, listPtr, index, 0, (objc-3), &(objv[3]));
}
/*