Permalink
Browse files

simplify string escape reduction

  • Loading branch information...
moritz committed Jun 3, 2010
1 parent 23bdbdf commit 320903e30e76834c52fe56de0b24e1490630ff37
Showing with 6 additions and 7 deletions.
  1. +6 −7 lib/JSON/Tiny/Actions.pm
View
@@ -36,13 +36,12 @@ method str_escape($/) {
if $<xdigit> {
make chr(:16($<xdigit>.join));
} else {
- given ~$/ {
- when '\\' { make '\\'; }
- when 'n' { make "\n"; }
- when 't' { make "\t"; }
- when 'f' { make "\f"; }
- when 'r' { make "\r"; }
- }
+ my %h = '\\' => "\\",
+ 'n' => "\n",
+ 't' => "\t",
+ 'f' => "\f",
+ 'r' => "\r";
+ make %h{$/};
}
}

0 comments on commit 320903e

Please sign in to comment.