summaryrefslogtreecommitdiffstats
path: root/generic/tclListObj.c
diff options
context:
space:
mode:
authorpooryorick <com.digitalsmarties@pooryorick.com>2016-07-28 21:49:35 (GMT)
committerpooryorick <com.digitalsmarties@pooryorick.com>2016-07-28 21:49:35 (GMT)
commit3a49ad6c4bdee4485eb5fd692e7ba8d1a5d0f637 (patch)
tree7f0dfdde40a71ae52f7e38e3031a8b0066ea0f31 /generic/tclListObj.c
parentd01a6c61924702ec32f0345567fead78978e1c54 (diff)
parentf1810dae6c5de7512c2d388b7631b7dc4a888928 (diff)
downloadtcl-3a49ad6c4bdee4485eb5fd692e7ba8d1a5d0f637.zip
tcl-3a49ad6c4bdee4485eb5fd692e7ba8d1a5d0f637.tar.gz
tcl-3a49ad6c4bdee4485eb5fd692e7ba8d1a5d0f637.tar.bz2
merge pyk-listdictstringreppyk_trunk
Diffstat (limited to 'generic/tclListObj.c')
-rw-r--r--generic/tclListObj.c25
1 files changed, 18 insertions, 7 deletions
diff --git a/generic/tclListObj.c b/generic/tclListObj.c
index 14b8a14..0852c8c 100644
--- a/generic/tclListObj.c
+++ b/generic/tclListObj.c
@@ -13,6 +13,7 @@
#include "tclInt.h"
+#define LIST(listObj) ((List *)(listObj)->internalRep.twoPtrValue.ptr1)
/*
* Prototypes for functions defined later in this file:
*/
@@ -20,8 +21,8 @@
static List * AttemptNewList(Tcl_Interp *interp, int objc,
Tcl_Obj *const objv[]);
static List * NewListIntRep(int objc, Tcl_Obj *const objv[], int p);
-static void DupListInternalRep(Tcl_Obj *srcPtr, Tcl_Obj *copyPtr);
static void FreeListInternalRep(Tcl_Obj *listPtr);
+static void DupListInternalRep(Tcl_Obj *srcPtr, Tcl_Obj *copyPtr);
static int SetListFromAny(Tcl_Interp *interp, Tcl_Obj *objPtr);
static void UpdateStringOfList(Tcl_Obj *listPtr);
@@ -1822,18 +1823,28 @@ SetListFromAny(
Tcl_Interp *interp, /* Used for error reporting if not NULL. */
Tcl_Obj *objPtr) /* The object to convert. */
{
+ Tcl_Obj *listPtr;
List *listRepPtr;
Tcl_Obj **elemPtrs;
/*
- * Dictionaries are a special case; they have a string representation such
- * that *all* valid dictionaries are valid lists. Hence we can convert
- * more directly. Only do this when there's no existing string rep; if
- * there is, it is the string rep that's authoritative (because it could
- * describe duplicate keys).
+ * Dictionaries are a special case; they may have stored a previous list
+ * representation
*/
- if (objPtr->typePtr == &tclDictType && !objPtr->bytes) {
+ listPtr = TclObjLookupTyped(objPtr, &tclListType);
+ if (listPtr != NULL) {
+ Tcl_IncrRefCount(listPtr);
+ TclFreeIntRep(objPtr);
+ DupListInternalRep(listPtr, objPtr);
+ Tcl_DecrRefCount(listPtr);
+ objPtr->typePtr = &tclListType;
+ /* To Do: Maybe keep the dict intrep around in case this object is
+ * used as a dict again */
+ return TCL_OK;
+ }
+
+ if (objPtr->typePtr == &tclDictType) {
Tcl_Obj *keyPtr, *valuePtr;
Tcl_DictSearch search;
int done, size;