From 7a55a1f5fa4ca17b09898e4b2e439b0291214a84 Mon Sep 17 00:00:00 2001 From: Guillaume Cottenceau Date: Mon, 23 Dec 2002 14:35:24 +0000 Subject: be more efficient in precomputing, previous situation could lead to several tens of seconds of wait in XFdrake-monitor --- perl-install/interactive/gtk.pm | 29 ++++++++++------------------- 1 file changed, 10 insertions(+), 19 deletions(-) (limited to 'perl-install/interactive') diff --git a/perl-install/interactive/gtk.pm b/perl-install/interactive/gtk.pm index d58195d81..c9cffa3b0 100644 --- a/perl-install/interactive/gtk.pm +++ b/perl-install/interactive/gtk.pm @@ -172,30 +172,21 @@ sub create_treeview_tree { } $wtree{$s}; }; - foreach (@l) { - my ($root, $leaf) = /(.*)$sep(.+)/ ? ($1, $2) : ('', $_); + + #- do some precomputing to not slowdown selection change and key press + my (%precomp, @ordered_keys); + mapn { + my ($root, $leaf) = $_[0] =~ /(.*)$sep(.+)/ ? ($1, $2) : ('', $_[0]); my $iter = $tree_model->append_set($parent->($root), [ 0 => $leaf ]); - $wleaves{$_} = $tree_model->get_path_str($iter); + my $pathstr = $tree_model->get_path_str($iter); $iter->free; - } + $precomp{$pathstr} = { value => $leaf, fullvalue => $_[0], listvalue => $_[1] }; + push @ordered_keys, $pathstr; + $wleaves{$_[0]} = $pathstr; + } \@l, $e->{list}; $_->free foreach values %wtree; undef %wtree; - #- do some precomputing to not slowdown selection change and key press - my (%precomp, @ordered_keys); - $tree_model->foreach(sub { - my (undef, $path_, $iter) = @_; - my ($path, $pathstr, @ll, $val, $listval); - $path = $path_->copy; - $pathstr = $path->to_string; - while ($path->get_depth) { unshift @ll, $tree_model->get($path, 0); $path->up } - $val = join($e->{separator}, @ll); - mapn { $listval = $_[1] if $val eq $_[0] } \@l, $e->{list}; - $precomp{$pathstr} = { value => $tree_model->get($iter, 0), fullvalue => $val, listvalue => $listval }; - push @ordered_keys, $pathstr; - 0 - }, undef); - my $select = sub { my ($path_str) = @_; my $path = Gtk2::TreePath->new_from_string($path_str); -- cgit v1.2.1