Next | Making Programs Faster | 61 |
sub append { my $self = shift; local *ptree = $self; for (@_) { next unless length; if (@ptree and !(ref $ptree[-1]) and !(ref $_)) { $ptree[-1] .= $_; } else { push @ptree, $_; } } }
What if we didn't bother to agglomerate strings?
Then append would become:
sub append { my $self = shift; push @$self, @_; }
It's easy to imagine that this would speed up append substantially
Next | Copyright © 2003 M. J. Dominus |