Changeset 22862 for src

Show
Ignore:
Timestamp:
11/03/08 21:15:43 (2 months ago)
Author:
azawawi
Message:

[STD_syntax_highlight] less memory usage... now works in < 512M ulimits

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • src/perl6/STD_syntax_highlight

    r22847 r22862  
    214214        next unless defined $loc[$i]; 
    215215        my $c = substr($src_text,$i,1); 
    216         my $tree = "@{$loc[$i]}"; 
    217  
     216        my $tree = ""; 
     217        for my $action_ref (@{$loc[$i]}) { 
     218            $tree .= ${$action_ref} . " "; 
     219        } 
    218220        if($tree ne $last_tree) { 
    219221            $str .= qq{<span id="tree_$i" style="display:none;">$last_tree</span>}; 
     
    309311        next unless defined $loc[$i]; 
    310312        my $c = substr($src_text,$i,1); 
    311         my $tree = "@{$loc[$i]}"; 
     313        my $tree = ""; 
     314        for my $action_ref (@{$loc[$i]}) { 
     315            $tree .= ${$action_ref} . " "; 
     316        } 
    312317        if($tree ne $last_tree) { 
    313318            my $rule; 
     
    380385        next unless defined $loc[$i]; 
    381386        my $c = substr($src_text,$i,1); 
    382         my $tree = "@{$loc[$i]}"; 
     387        my $tree = ""; 
     388        for my $action_ref (@{$loc[$i]}) { 
     389            $tree .= ${$action_ref} . " "; 
     390        } 
    383391        if($tree ne $last_tree) { 
    384392            my $rule; 
     
    428436    our $AUTOLOAD; 
    429437 
     438    my %action_refs = (); 
     439 
    430440    sub AUTOLOAD { 
    431441        my $self = shift; 
     
    435445        $AUTOLOAD =~ s/^Actions:://; 
    436446        $loc[$P] = [] if $loc[$P];      # in case we backtracked to here 
     447        my $action = $AUTOLOAD; 
     448        my $action_ref = $action_refs{$action}; 
     449        if(!$action_ref) { 
     450            $action_refs{$action} = $action_ref = \$action; 
     451        } 
    437452        for ($F..$P-1) { 
    438             unshift @{$loc[$_]}, $AUTOLOAD; 
     453            unshift @{$loc[$_]}, $action_ref; 
    439454        } 
    440455    }