Skip to content
This repository has been archived by the owner on Feb 22, 2018. It is now read-only.

Commit

Permalink
perf(parser): Use a switch statement for unescaping.
Browse files Browse the repository at this point in the history
  • Loading branch information
Robert Nagy authored and mhevery committed Jan 8, 2014
1 parent ae8be92 commit 28b68d1
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions lib/core/parser/characters.dart
Original file line number Diff line number Diff line change
Expand Up @@ -129,13 +129,12 @@ bool isExponentSign(int code) {
}

int unescape(int code) {
if (code & 1 == 1 || code < $f || code > $v) return code;
Map<int, int> escapes = const {
$n: $LF,
$f: $FF,
$r: $CR,
$t: $TAB,
$v: $VTAB };
int mapped = escapes[code];
return (mapped == null) ? code : mapped;
switch(code) {
case $n: return $LF;
case $f: return $FF;
case $r: return $CR;
case $t: return $TAB;
case $v: return $VTAB;
default: return code;
}
}

0 comments on commit 28b68d1

Please sign in to comment.