robertkrimen/otto — pull request #69 by kharin (2014-05-17 22:27:27+00:00)
Title: Implement strings without value16 (fixes #68)

Hello everyone! As promised, here's my take on the "value16 problem."

This PR fixes `newStringObject` generating a lot of garbage in case of intense string manipulation as well as `charCodeAt` and `charAt` not reusing `_stringObject`s value16. In my tests using utf8string.String outperformed any other methods solely by not allocating value16 whatsoever. (As in many use cases string's life expectancy in very low.)

For a simple React widget generating 256 `p`s, new implementation performs 15x faster. (500ms vs 7.5s)
```bash
echo "var global = {};" | cat - react.js test.js | otto
```
```javascript
var R;
if (global) R = global.React;

var App = R.createClass({
render: function() {
var r = [];
for(var i = 0; i < 256; i++) {
r.push(R.DOM.p({key: i}, this.props.text));
}
return R.DOM.div({}, r);
}
});

var d1 = Date.now();
console.log(R.renderComponentToString(App({text: "Hello, Hello!"})));
console.log(Date.now() - d1);
```

I think strings implementation might need some more love on that front, but I've tried to keep PR as concise as possible.

/cc: @tux21b