bestiejs/json3 — pull request #27 by oxyc (2013-03-23 12:13:46+00:00)
Title: Optimize lex()

In browsers string operations are quite expensive so for hot code it's a good idea to work with character codes instead.

As character codes make the code a lot more difficult to read and json3 is pure awesome from before, I only changed the most costly operations and kept the rest as before.

```
commit 65d583c7272967159cabc09ecec421eb781cdfdf
Author: Oskar Schöldström
Date: Sat Mar 23 13:45:24 2013 +0200

Optimize for the common case where a string is valid

before x 108,854 ops/sec ±0.50% (93 runs sampled)
after x 129,460 ops/sec ±0.42% (101 runs sampled)

commit dabbd930c819df00605d351ac89aebb7b2fb9892
Author: Oskar Schöldström
Date: Sat Mar 23 13:25:03 2013 +0200

Optimize token type branching in lex()

before x 70,844 ops/sec ±0.68% (99 runs sampled)
after x 108,854 ops/sec ±0.50% (93 runs sampled)
```

The performance is measured with node, I actually have no idea what the gain is on browsers that will use these functions. If anyone has access to proper VMs the changes can be benchmarked on http://jsperf.com/json3/20 (these are slightly more optimized as lex() only uses char codes)