[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index][Thread Index][Top&Search][Original]
[PATCH] Pod::InputObjects performance de-pessimization
This summer I gave a tutorial at the Perl Conference on benchmarking
and performance tuning. One of the examples I selected was pod2man,
since it's widely used, everyone has heard of it, and it's really slow.
In the course of analyzing pod2man, I found that one of the hot spots
was the folllowing function, which is about four times as complicated
as it needs to be. The obvious change simplified the code and sped up
pod2man by several percent overall.
All tests still pass.
--- lib/Pod/InputObjects.pm 2003/08/22 06:29:19 1.1
+++ lib/Pod/InputObjects.pm 2003/08/22 07:52:15
@@ -844,26 +844,14 @@
=head2 $ptree-E<gt>B<append()>
-This method appends the given text or parse-tree to the current parse-tree.
-If the last item on the parse-tree is text and the argument is also text,
-then the text is appended to the last item (not added as a separate string).
-Otherwise the argument is added as a new string or parse-tree I<after>
-the current one.
+This method appends the given text, parse-trees, or both to the
+current parse-tree.
=cut
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, $_;
- }
- }
+ push @$self, @_;
}
=head2 $ptree-E<gt>B<raw_text()>
[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index][Thread Index][Top&Search][Original]