Avoid regular expression syntax which can negatively impact performance.

        Codemerge from LJ; adapted for Dreamwidth by <user name=kareila>. 

diffs (42 lines):

diff -r 99d752ac765f -r d9c442fda58a S2/Tokenizer.pm
--- a/S2/Tokenizer.pm   Mon Jun 07 03:03:57 2010 +0000
+++ b/S2/Tokenizer.pm   Sat Sep 11 09:41:19 2010 -0500
@@ -148,8 +148,8 @@ sub makeToken # () method private : Toke
         }
     }
 
-    if ($$c =~ /\G\s+/gc) {
-        my $ws = $&;
+    if ( $$c =~ /\G(\s+)/gc ) {
+        my $ws = $1;
         return S2::TokenWhitespace->new($ws);
     }
 
@@ -157,8 +157,8 @@ sub makeToken # () method private : Toke
         return S2::TokenPunct->new($1);
     }
 
-    if ($$c =~ /\G[a-zA-Z\_]\w*/gc) {
-        my $ident = $&;
+    if ( $$c =~ /\G([a-zA-Z\_]\w*)/gc ) {
+        my $ident = $1;
         return S2::TokenIdent->new($ident);
     }
 
@@ -167,12 +167,12 @@ sub makeToken # () method private : Toke
         return S2::TokenIntegerLiteral->new($iv);
     }
     
-    if ($$c =~ /\G\#.*\n?/gc) {
-        return S2::TokenComment->new($&);
+    if ( $$c =~ /\G(\#.*\n?)/gc ) {
+        return S2::TokenComment->new( $1 );
     }
 
-    if ($$c =~ /.+/gc) {
-        S2::error($this->getPos(), "Parse error!  Unknown token.  ($&)");
+    if ( $$c =~ /(.+)/gc ) {
+        S2::error( $this->getPos(), "Parse error!  Unknown token.  ($1)" );
     }
     
     return undef;
_______________________________________________
dw-changelog mailing list
[email protected]
http://lists.dwscoalition.org/mailman/listinfo/dw-changelog

Reply via email to