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

Commit

Permalink
perf(parser): Faster character tests.
Browse files Browse the repository at this point in the history
Performance
===========

lexer_perf:

Dart VM - Old:

ident: => 1,182,988 ops/sec (1 us) stdev(0.1318)
ident-path: => 1,805,782 ops/sec (1 us) stdev(0.26363)
num: => 1,269,793 ops/sec (1 us) stdev(0.17873)
num-double: => 760,554 ops/sec (1 us) stdev(0.13409)
string: => 1,968,371 ops/sec (1 us) stdev(0.20383)
string-escapes: => 607,930 ops/sec (2 us) stdev(0.08734)

Dart VM - New:

ident: => 2,068,501 ops/sec (0 us) stdev(0.05876)
ident-path: => 3,234,291 ops/sec (0 us) stdev(0.09304)
num: => 1,972,071 ops/sec (1 us) stdev(0.16793)
num-double: => 953,725 ops/sec (1 us) stdev(0.022)
string: => 2,108,910 ops/sec (0 us) stdev(0.08699)
string-escapes: => 712,866 ops/sec (1 us) stdev(0.02661)
  • Loading branch information
Robert Nagy authored and mhevery committed Jan 8, 2014
1 parent f2651d4 commit ae8be92
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions lib/core/parser/characters.dart
Original file line number Diff line number Diff line change
Expand Up @@ -98,12 +98,7 @@ const int $TILDE = 126;
const int $NBSP = 160;

bool isWhitespace(int code) {
return (code == $SPACE)
|| (code == $CR)
|| (code == $LF)
|| (code == $NBSP)
|| (code == $TAB)
|| (code == $VTAB);
return (code >= $TAB && code <= $SPACE) || (code == $NBSP);
}

bool isIdentifierStart(int code) {
Expand Down Expand Up @@ -134,6 +129,7 @@ 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,
Expand Down

0 comments on commit ae8be92

Please sign in to comment.