hand-optimize Buffer constructor
The Buffer constructor is used pervasively throughout io.js, yet it was
one of the most unwieldy functions in core. This commit breaks up the
constructor into several small functions in a way that makes V8 happy.
About 8-10% CPU time was attributed to the constructor function before
in buffer-heavy benchmarks. That pretty much drops to zero now because
V8 can now easily inline it at the call site. It shortens the running
time of the following simple benchmark by about 15%:
for (var i = 0; i < 25e6; ++i) new Buffer(1);
And about 8% from this benchmark:
for (var i = 0; i < 1e7; ++i) new Buffer('x', 'ucs2');
From
https://github.com/iojs/io.js/commit/
bbf54a554ababa91ced243acb0d2721bc19
eb1dc