From: <mth...@us...> - 2009-07-26 23:16:27
|
Revision: 10280 http://openmsx.svn.sourceforge.net/openmsx/?rev=10280&view=rev Author: mthuurne Date: 2009-07-26 23:16:19 +0000 (Sun, 26 Jul 2009) Log Message: ----------- Replaced menu state stack by a series of arrays. The problem with the lists was that when moving from one scrolling list item to another, the data was unpacked 13 times. This got slow with big lists (directories with ~500 files) on CPUs that are just powerful enough to run openMSX (like in portable devices). Modified Paths: -------------- openmsx/trunk/share/scripts/osd_menu.tcl Modified: openmsx/trunk/share/scripts/osd_menu.tcl =================================================================== --- openmsx/trunk/share/scripts/osd_menu.tcl 2009-07-26 17:35:04 UTC (rev 10279) +++ openmsx/trunk/share/scripts/osd_menu.tcl 2009-07-26 23:16:19 UTC (rev 10280) @@ -20,32 +20,42 @@ } } -variable menuinfos [list] +variable menulevels 0 variable main_menu proc push_menu_info {} { - variable menuinfos - lappend menuinfos [uplevel {list $name $menutexts $selectinfo $selectidx $scrollidx $on_close}] + variable menulevels + incr menulevels 1 + set levelname "menuinfo_$menulevels" + variable $levelname + array set $levelname [uplevel { list name $name menutexts $menutexts selectinfo $selectinfo selectidx $selectidx scrollidx $scrollidx on_close $on_close }] } -proc unpack_menu_info { } { - variable menuinfos - set data [lindex $menuinfos end] - set cmd [list foreach {name menutexts selectinfo selectidx scrollidx on_close} $data {}] - uplevel $cmd +proc peek_menu_info {} { + variable menulevels + uplevel upvar #0 osd_menu::menuinfo_$menulevels menuinfo } +proc unpack_menu_info {} { + peek_menu_info + uplevel [list set name "$menuinfo(name)"] + uplevel [list set menutexts "$menuinfo(menutexts)"] + uplevel [list set selectinfo "$menuinfo(selectinfo)"] + uplevel [list set selectidx "$menuinfo(selectidx)"] + uplevel [list set scrollidx "$menuinfo(scrollidx)"] + uplevel [list set on_close "$menuinfo(on_close)"] +} proc set_selectidx { value } { - variable menuinfos - lset menuinfos {end 3} $value + peek_menu_info + array set menuinfo [list selectidx $value] } proc set_scrollidx { value } { - variable menuinfos - lset menuinfos {end 4} $value + peek_menu_info + array set menuinfo [list scrollidx $value] } proc menu_create { menu_def_list } { - variable menuinfos + variable menulevels - set name "menu[expr [llength $menuinfos] + 1]" + set name "menu[expr $menulevels + 1]" array set menudef $menu_def_list @@ -122,20 +132,22 @@ } proc menu_close_top {} { + variable menulevels unpack_menu_info menu_on_deselect $selectinfo $selectidx uplevel #0 $on_close osd destroy $name - variable menuinfos - set menuinfos [lreplace $menuinfos end end] - if {[llength $menuinfos] == 0} { + peek_menu_info + array unset menuinfo + incr menulevels -1 + if {$menulevels == 0} { menu_last_closed } } proc menu_close_all {} { - variable menuinfos - while {[llength $menuinfos]} { + variable menulevels + while {$menulevels} { menu_close_top } } @@ -199,8 +211,8 @@ menu_close_all } proc main_menu_toggle {} { - variable menuinfos - if [llength $menuinfos] { + variable menulevels + if {$menulevels} { # there is at least one menu open, close it menu_close_all } else { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |