(Message p5/mjd:873)
/home/mjd/bin/mailpager 873
Forwarded: Mon, 15 May 2006 16:04:42 -0400
Return-Path: perl5-porters-return-80722-mjd-p5p2=plover.com@perl.org
Delivery-Date: Fri Aug 22 07:54:32 2003
Return-Path: <perl5-porters-return-80722-mjd-p5p2=plover.com@perl.org>
Delivered-To: mjd-p5p2@plover.com
Received: (qmail 25826 invoked from network); 22 Aug 2003 07:54:32 -0000
Received: from onion.develooper.com (HELO onion.perl.org) (63.251.223.166)
  by plover.com with SMTP; 22 Aug 2003 07:54:32 -0000
Received: (qmail 47036 invoked by uid 1005); 22 Aug 2003 07:53:42 -0000
Mailing-List: contact perl5-porters-help@perl.org; run by ezmlm
Precedence: bulk
list-help: <mailto:perl5-porters-help@perl.org>
list-unsubscribe: <mailto:perl5-porters-unsubscribe@perl.org>
list-post: <mailto:perl5-porters@perl.org>
X-List-Archive: <http://nntp.perl.org/group/perl.perl5.porters/80722>
Delivered-To: mailing list perl5-porters@perl.org
Received: (qmail 47017 invoked by uid 76); 22 Aug 2003 07:53:42 -0000
Delivered-To: perl5-porters@perl.org
Message-ID: <20030822075346.25736.qmail@plover.com>
To: perl5-porters@perl.org
Subject: [PATCH] Pod::InputObjects performance de-pessimization
Organization: Plover Systems
Date: Fri, 22 Aug 2003 03:53:46 -0400
From: Mark Jason Dominus <mjd@plover.com>
X-SMTPD: qpsmtpd/0.27-dev, http://develooper.com/code/qpsmtpd/
X-Spam-Check-By: one.develooper.com
X-Spam-Status: No, hits=0.9 required=7.0 tests=CARRIAGE_RETURNS,NOSPAM_INC,SPAM_PHRASE_00_01 version=2.44
X-SMTPD: qpsmtpd/0.26, http://develooper.com/code/qpsmtpd/


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()>
