diff options
author | griffin <briang42@easystreet.net> | 2022-08-30 17:56:36 (GMT) |
---|---|---|
committer | griffin <briang42@easystreet.net> | 2022-08-30 17:56:36 (GMT) |
commit | d06b33cd9433fa01e505824932e316301348a970 (patch) | |
tree | e1c8414aa6f966cf5f061b5de23097d447f0a113 /generic/tclCmdIL.c | |
parent | 603b76f9107442e86b4f3bfd8c506097ca661fa6 (diff) | |
parent | 8c034cf9ce62c27025614676e999df1db4e75686 (diff) | |
download | tcl-d06b33cd9433fa01e505824932e316301348a970.zip tcl-d06b33cd9433fa01e505824932e316301348a970.tar.gz tcl-d06b33cd9433fa01e505824932e316301348a970.tar.bz2 |
Sync with core-8-branch listObj changes.
Diffstat (limited to 'generic/tclCmdIL.c')
-rw-r--r-- | generic/tclCmdIL.c | 45 |
1 files changed, 31 insertions, 14 deletions
diff --git a/generic/tclCmdIL.c b/generic/tclCmdIL.c index bcee3ca..fa8d1a5 100644 --- a/generic/tclCmdIL.c +++ b/generic/tclCmdIL.c @@ -19,8 +19,9 @@ #include "tclInt.h" #include "tclRegexp.h" -#include <math.h> #include "tclArithSeries.h" +#include <math.h> +#include <assert.h> /* * During execution of the "lsort" command, structures of the following type @@ -2956,10 +2957,15 @@ Tcl_LrepeatObjCmd( listPtr = Tcl_NewListObj(totalElems, NULL); if (totalElems) { - List *listRepPtr = ListRepPtr(listPtr); - - listRepPtr->elemCount = elementCount*objc; - dataArray = listRepPtr->elements; + ListRep listRep; + ListObjGetRep(listPtr, &listRep); + dataArray = ListRepElementsBase(&listRep); + listRep.storePtr->numUsed = totalElems; + if (listRep.spanPtr) { + /* Future proofing in case Tcl_NewListObj returns a span */ + listRep.spanPtr->spanStart = listRep.storePtr->firstUsed; + listRep.spanPtr->spanLength = listRep.storePtr->numUsed; + } } /* @@ -3150,14 +3156,21 @@ Tcl_LreverseObjCmd( } if (Tcl_IsShared(objv[1]) - || (ListRepPtr(objv[1])->refCount > 1)) { /* Bug 1675044 */ + || ListObjRepIsShared(objv[1])) { /* Bug 1675044 */ Tcl_Obj *resultObj, **dataArray; - List *listRepPtr; + ListRep listRep; resultObj = Tcl_NewListObj(elemc, NULL); - listRepPtr = ListRepPtr(resultObj); - listRepPtr->elemCount = elemc; - dataArray = listRepPtr->elements; + + /* Modify the internal rep in-place */ + ListObjGetRep(resultObj, &listRep); + listRep.storePtr->numUsed = elemc; + dataArray = ListRepElementsBase(&listRep); + if (listRep.spanPtr) { + /* Future proofing */ + listRep.spanPtr->spanStart = listRep.storePtr->firstUsed; + listRep.spanPtr->spanLength = listRep.storePtr->numUsed; + } for (i=0,j=elemc-1 ; i<elemc ; i++,j--) { dataArray[j] = elemv[i]; @@ -4883,12 +4896,12 @@ Tcl_LsortObjCmd( */ if (sortInfo.resultCode == TCL_OK) { - List *listRepPtr; + ListRep listRep; Tcl_Obj **newArray, *objPtr; resultPtr = Tcl_NewListObj(sortInfo.numElements * groupSize, NULL); - listRepPtr = ListRepPtr(resultPtr); - newArray = listRepPtr->elements; + ListObjGetRep(resultPtr, &listRep); + newArray = ListRepElementsBase(&listRep); if (group) { for (i=0; elementPtr!=NULL ; elementPtr=elementPtr->nextPtr) { idx = elementPtr->payload.index; @@ -4917,7 +4930,11 @@ Tcl_LsortObjCmd( Tcl_IncrRefCount(objPtr); } } - listRepPtr->elemCount = i; + listRep.storePtr->numUsed = i; + if (listRep.spanPtr) { + listRep.spanPtr->spanStart = listRep.storePtr->firstUsed; + listRep.spanPtr->spanLength = listRep.storePtr->numUsed; + } Tcl_SetObjResult(interp, resultPtr); } |