C
Clint Olsen
Hi:
In the generated code, Yapp places in the entire yystate and yyrules array
references directly in the call. For my application, which calls the
Parser thousands of times on a grammar that is almost 1000 lines, the
overhead to recreate this data structure each time dominates the run time.
Intuition says that moving this to a file-scoped lexical or global in the
package should mean that overhead is only paid once, and it does. For me,
this change results in almost a 4x speed improvement.
-Clint
--- lib/Parse/Yapp/Output.pm Sun Feb 11 07:29:25 2001
+++ Output.pm Sun Feb 8 00:30:59 2004
@@ -53,16 +53,18 @@
<<$head>>
+my $yystates = <<$states>>;
+
+my $yyrules = <<$rules>>;
+
sub new {
my($class)=shift;
ref($class)
and $class=ref($class);
my($self)=$class->SUPER::new( yyversion => '<<$version>>',
- yystates =>
-<<$states>>,
- yyrules =>
-<<$rules>>,
+ yystates => $yystates,
+ yyrules => $yyrules,
@_);
bless($self,$class);
}
In the generated code, Yapp places in the entire yystate and yyrules array
references directly in the call. For my application, which calls the
Parser thousands of times on a grammar that is almost 1000 lines, the
overhead to recreate this data structure each time dominates the run time.
Intuition says that moving this to a file-scoped lexical or global in the
package should mean that overhead is only paid once, and it does. For me,
this change results in almost a 4x speed improvement.
-Clint
--- lib/Parse/Yapp/Output.pm Sun Feb 11 07:29:25 2001
+++ Output.pm Sun Feb 8 00:30:59 2004
@@ -53,16 +53,18 @@
<<$head>>
+my $yystates = <<$states>>;
+
+my $yyrules = <<$rules>>;
+
sub new {
my($class)=shift;
ref($class)
and $class=ref($class);
my($self)=$class->SUPER::new( yyversion => '<<$version>>',
- yystates =>
-<<$states>>,
- yyrules =>
-<<$rules>>,
+ yystates => $yystates,
+ yyrules => $yyrules,
@_);
bless($self,$class);
}