Given following stress-test script:
use Tcl::Tk qw(:perlTk);
my $t0=time;
my $mw = tkinit;
my $tw = $mw->Scrolled('Text',-height=>2)->pack;
for my $stresser ('a'..'zzz') {
$tw->windowCreate('end',-window=>$tw->Button(-text=>$stresser));
if ($stresser =~ /z$/) {
$tw->insert('end',"\n") ;
$tw->seeEnd;
$tw->update;
}
}
my $t1=time;
print STDERR "time=".($t1-$t0)."\n";
MainLoop;
it occures that approximately after 1000th insertion of widget further
insertions are visually slower, and then slower yet, and slower and slower.
However, when changing a line in Tcl::Tk::declare_widget sub
my $id = $path=~/^\./ ? $int->invoke('winfo','id',$path) : $path;
to
my $id = $path;
it appears no slowness.
Changing this way results in changing some internal logic, but all other
things remains functional (including -d:tcltkdb, which has multiple
interpreters)
So I am going to do this change.
Also, I am going to commit few other small speed improvements:
- declare_widget now takes additional 3rd argument, which package
widget should be blessed to. (otherwise there were more consequent
blesses: first into Tcl::Tk::Widget, and then, say, into
Tcl::Tk::Widget::Text)
- $gwcnt incremented every time widget path is invented, so
simplifying logic and making it faster.
Vadim.
|