diff options
author | dgp <dgp@users.sourceforge.net> | 2018-04-19 01:39:38 (GMT) |
---|---|---|
committer | dgp <dgp@users.sourceforge.net> | 2018-04-19 01:39:38 (GMT) |
commit | df94eecf119611a2fa8de1abb3abe59269be7550 (patch) | |
tree | 20e9d2ee27278c74ce9326bb1f54b69767315921 | |
parent | 80e5aed49e2cac237b9d91db0f5dc1139c6462dd (diff) | |
download | tcl-df94eecf119611a2fa8de1abb3abe59269be7550.zip tcl-df94eecf119611a2fa8de1abb3abe59269be7550.tar.gz tcl-df94eecf119611a2fa8de1abb3abe59269be7550.tar.bz2 |
An [array set] from a dict can only take shortcuts when the dict is "pure",
that is, has no string rep.
-rw-r--r-- | generic/tclVar.c | 2 | ||||
-rw-r--r-- | tests/var.test | 12 |
2 files changed, 13 insertions, 1 deletions
diff --git a/generic/tclVar.c b/generic/tclVar.c index e540c49..d4e5339 100644 --- a/generic/tclVar.c +++ b/generic/tclVar.c @@ -3411,7 +3411,7 @@ TclArraySet( * Install the contents of the dictionary or list into the array. */ - if (arrayElemObj->typePtr == &tclDictType) { + if (arrayElemObj->typePtr == &tclDictType && arrayElemObj->bytes == NULL) { Tcl_Obj *keyPtr, *valuePtr; Tcl_DictSearch search; int done; diff --git a/tests/var.test b/tests/var.test index 30e340e..aadeb34 100644 --- a/tests/var.test +++ b/tests/var.test @@ -761,6 +761,18 @@ test var-17.1 {TclArraySet [Bug 1669489]} -setup { } -cleanup { unset -nocomplain ::a ::elements } -result {} +test var-17.2 {TclArraySet Dict shortcut only on pure value} -setup { + unset -nocomplain a d + set d {p 1 p 2} + dict get $d p + set foo 0 +} -body { + trace add variable a write "[list incr [namespace which -variable foo]];#" + array set a $d + set foo +} -cleanup { + unset -nocomplain a d foo +} -result 2 test var-18.1 {array unset and unset traces: Bug 2939073} -setup { set already 0 |