Overview
| Artifact ID: | 72c2569c7165e74966d6e871428ccf685d5b31a9 |
|---|---|
| Ticket: | dfccbeb623afe3f6db537614a008a0bc0cef4fdf
lappend very slow in tcl 8.6 |
| User & Date: | anonymous on 2014-08-19 16:09:26 |
Changes
- assignee changed to: "nobody"
- closer changed to: "nobody"
- cmimetype changed to: "text/plain"
- comment changed to:
The following snippet of code takes about 30 seconds in Tcl 8.6, but runs in well under a second in Tcl 8.5. The problem is something to do with the upvar, and with the fact that "lappend" appends two elements at once -- if you replace the call with two "lappend"s of one element each, it runs fast. ============================= proc ArrayGetSorted {arrayPtr} { set result {} upvar 1 $arrayPtr arrayName set nameList [array names arrayName] puts "Start [clock seconds]" foreach name $nameList { lappend result $name $arrayName($name) } puts "Done [clock seconds]" return $result } for {set n 0} {$n < 40000} {incr n} { set arr([list top [expr rand()] [expr rand()]]) data } ArrayGetSorted arr ============================= - foundin changed to: "8.6"
- is_private changed to: "0"
- login: "anonymous"
- priority changed to: "5 Medium"
- private_contact changed to: "21e680c66afc6863cbbaf0aa5b26c9e8a4429339"
- resolution changed to: "None"
- severity changed to: "Important"
- status changed to: "Open"
- submitter changed to: "anonymous"
- subsystem changed to: "17. Commands I-L"
- title changed to: "lappend very slow in tcl 8.6"
- type changed to: "Bug"