Permalink
Browse files

Replace 5 subst($) calls with a single trans(@)

This is actually ~10% slower in current rakudo, but hopefully pushing the
cleverness down one level will allow it to be faster in the long run.
  • Loading branch information...
flussence committed Jun 26, 2012
1 parent 18eec5f commit 5be64c8fa36f3ff13c6e3bbe7f6256f2608c6365
Showing with 2 additions and 5 deletions.
  1. +2 −5 lib/Pod/To/HTML.pm
View
@@ -21,11 +21,8 @@ my @footnotes;
sub escape_html(Str $str) returns Str {
return $str unless $str ~~ /<[&<>"']>/;
- $str.subst(q{&}, q{&amp;}, :g)\
- .subst(q{<}, q{&lt;}, :g)\
- .subst(q{>}, q{&gt;}, :g)\
- .subst(q{"}, q{&quot;}, :g)\
- .subst(q{'}, q{&#39;}, :g);
+ $str.trans( [ q{&}, q{<}, q{>}, q{"}, q{'} ] =>
+ [ q{&amp;}, q{&lt;}, q{&gt;}, q{&quot;}, q{&#39;} ] );
}
#= Converts a Pod tree to a HTML document.

0 comments on commit 5be64c8

Please sign in to comment.