[Cpan-forum-commit] rev 229 - in trunk: . lib/CPAN/Forum

svn at pti.co.il svn at pti.co.il
Sun Sep 17 21:46:22 IDT 2006


Author: gabor
Date: 2006-09-17 14:46:15 -0400 (Sun, 17 Sep 2006)
New Revision: 229

Modified:
   trunk/
   trunk/lib/CPAN/Forum/Markup.pm
Log:
make the parser object singleton in order to reduce time spent creating it



Property changes on: trunk
___________________________________________________________________
Name: svk:merge
   - 8c4c90e1-83eb-0310-96eb-e7cb62807872:/local/cpan-forum:11336
   + 8c4c90e1-83eb-0310-96eb-e7cb62807872:/local/cpan-forum:11337

Modified: trunk/lib/CPAN/Forum/Markup.pm
===================================================================
--- trunk/lib/CPAN/Forum/Markup.pm	2006-09-17 18:45:56 UTC (rev 228)
+++ trunk/lib/CPAN/Forum/Markup.pm	2006-09-17 18:46:15 UTC (rev 229)
@@ -5,6 +5,8 @@
 use CGI qw();
 use Parse::RecDescent;
 
+my $parser;
+
 =head2 new
 
 Create the markup grammar
@@ -13,6 +15,7 @@
 
 sub new {
     my ($class) = @_;
+
     my $self = bless {}, $class;
     
     $self->{grammar} = q {
@@ -130,7 +133,10 @@
 
 sub parser {
     my ($self) = @_;
-    return Parse::RecDescent->new($self->{grammar});
+    if (not $parser) {
+        $parser = Parse::RecDescent->new($self->{grammar});
+    }
+    return $parser;
 }
 
 =head2 posting_process



More information about the Cpan-forum-commit mailing list