summaryrefslogtreecommitdiffstats
path: root/library
diff options
context:
space:
mode:
authordkf <donal.k.fellows@manchester.ac.uk>2005-06-03 10:02:20 (GMT)
committerdkf <donal.k.fellows@manchester.ac.uk>2005-06-03 10:02:20 (GMT)
commita8a6c5c794aec61e5150e68e523c9613e7f268a9 (patch)
tree09403f42f5cb2b0d85eb12ecc1bd6311da4f818c /library
parentebcab86c0ad3ebc55ffcc3a60ebceed9ab9fbdce (diff)
downloadtcl-a8a6c5c794aec61e5150e68e523c9613e7f268a9.zip
tcl-a8a6c5c794aec61e5150e68e523c9613e7f268a9.tar.gz
tcl-a8a6c5c794aec61e5150e68e523c9613e7f268a9.tar.bz2
Remove blatant inefficiency in [parray]
Diffstat (limited to 'library')
-rw-r--r--library/parray.tcl7
1 files changed, 4 insertions, 3 deletions
diff --git a/library/parray.tcl b/library/parray.tcl
index 92655b2..e331d4d 100644
--- a/library/parray.tcl
+++ b/library/parray.tcl
@@ -1,7 +1,7 @@
# parray:
# Print the contents of a global array on stdout.
#
-# RCS: @(#) $Id: parray.tcl,v 1.3 1998/09/14 18:40:03 stanton Exp $
+# RCS: @(#) $Id: parray.tcl,v 1.4 2005/06/03 10:02:23 dkf Exp $
#
# Copyright (c) 1991-1993 The Regents of the University of California.
# Copyright (c) 1994 Sun Microsystems, Inc.
@@ -16,13 +16,14 @@ proc parray {a {pattern *}} {
error "\"$a\" isn't an array"
}
set maxl 0
- foreach name [lsort [array names array $pattern]] {
+ set names [lsort [array names array $pattern]]
+ foreach name $names {
if {[string length $name] > $maxl} {
set maxl [string length $name]
}
}
set maxl [expr {$maxl + [string length $a] + 2}]
- foreach name [lsort [array names array $pattern]] {
+ foreach name $names {
set nameString [format %s(%s) $a $name]
puts stdout [format "%-*s = %s" $maxl $nameString $array($name)]
}