summaryrefslogtreecommitdiffstats
path: root/generic/tclListObj.c
diff options
context:
space:
mode:
authordkf <donal.k.fellows@manchester.ac.uk>2008-09-10 13:03:02 (GMT)
committerdkf <donal.k.fellows@manchester.ac.uk>2008-09-10 13:03:02 (GMT)
commiteb97dfe76d6d46cf1b3c040b8a907305e5300afe (patch)
tree505549710d71ed6f9ba0007bf5973534e1f03730 /generic/tclListObj.c
parent15f99b3fa80902c78a829d71b3d6159e9769cac1 (diff)
downloadtcl-eb97dfe76d6d46cf1b3c040b8a907305e5300afe.zip
tcl-eb97dfe76d6d46cf1b3c040b8a907305e5300afe.tar.gz
tcl-eb97dfe76d6d46cf1b3c040b8a907305e5300afe.tar.bz2
Fix efficiency bug detected by Kieran Elby.
Diffstat (limited to 'generic/tclListObj.c')
-rw-r--r--generic/tclListObj.c13
1 files changed, 11 insertions, 2 deletions
diff --git a/generic/tclListObj.c b/generic/tclListObj.c
index 7505569..aebaee8 100644
--- a/generic/tclListObj.c
+++ b/generic/tclListObj.c
@@ -10,7 +10,7 @@
* See the file "license.terms" for information on usage and redistribution of
* this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tclListObj.c,v 1.52 2008/08/23 10:54:24 dkf Exp $
+ * RCS: @(#) $Id: tclListObj.c,v 1.53 2008/09/10 13:03:33 dkf Exp $
*/
#include "tclInt.h"
@@ -428,7 +428,16 @@ Tcl_ListObjGetElements(
if (listPtr->typePtr != &tclListType) {
int result, length;
- (void) TclGetStringFromObj(listPtr, &length);
+ /*
+ * Don't get the string version of a dictionary; that transformation
+ * is not lossy, but is expensive.
+ */
+
+ if (listPtr->typePtr == &tclDictType) {
+ (void) Tcl_DictObjSize(NULL, listPtr, &length);
+ } else {
+ (void) TclGetStringFromObj(listPtr, &length);
+ }
if (!length) {
*objcPtr = 0;
*objvPtr = NULL;