Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: 72c2569c7165e74966d6e871428ccf685d5b31a9
Ticket: dfccbeb623afe3f6db537614a008a0bc0cef4fdf
lappend very slow in tcl 8.6
User & Date: anonymous on 2014-08-19 16:09:26
Changes

  1. assignee changed to: "nobody"
  2. closer changed to: "nobody"
  3. cmimetype changed to: "text/plain"
  4. 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
    =============================
    
  5. foundin changed to: "8.6"
  6. is_private changed to: "0"
  7. login: "anonymous"
  8. priority changed to: "5 Medium"
  9. private_contact changed to: "21e680c66afc6863cbbaf0aa5b26c9e8a4429339"
  10. resolution changed to: "None"
  11. severity changed to: "Important"
  12. status changed to: "Open"
  13. submitter changed to: "anonymous"
  14. subsystem changed to: "17. Commands I-L"
  15. title changed to: "lappend very slow in tcl 8.6"
  16. type changed to: "Bug"