joyent/node — pull request #3228 by TooTallNate (2012-05-06 20:07:43+00:00)
Title: buffer: make SlowBuffer inherit from Buffer

I wanted people to comment on this one because it's somewhat controversial. To anyone who doesn't like the `__proto__` usage, the justification is that we do the same thing to the `process` object to make it be an EventEmtter.

But basically this frees us from manually having to copy over functions to SlowBuffer's prototype (which has bitten us multiple times in the past). It's also nice for modules like `buffertools` or my new `ref` which extend Buffer's prototype, and therefore wouldn't [have to do so for SlowBuffer as well](https://github.com/TooTallNate/ref/blob/15b272bcb352d0af4ebec8b96e03b8c5a93bdfa5/lib/ref.js#L427-439).

As an added bonus, the `inspect()` function is now shared between Buffer and SlowBuffer, removing some duplicate code. There's probably more functions that we could share, but I figured there's probably speed optimizations that should be left in place.

Thoughts?

/cc @isaacs @bnoordhuis @piscisaureus