On Fri, Jan 4, 2013 at 9:23 PM, Trevor Norris <trev.nor...@gmail.com> wrote:
> This is for all the committers out there.
>
> While working on my latest Buffers PR, noticed there are
> undocumented/unenforced ways things can go wrong. Say, for example, a user
> wants to extend Buffer with their own set of methods/properties and just
> happen to name one of them 'parent' or 'offset'. imho The least I would like
> to see them mentioned in the docs, and possibly underscored.

I'm not that worried about people sub-classing Buffer because they
shouldn't really be doing that in the first place.  Buffer is the
closest thing node.js has to a primitive and people should treat it as
such.

> The following are more complex changes I would like to implement, but really
> need feedback whether they'd be accepted or not:
>
> I noticed that every Buffer() call has to reach out to C. Either to create a
> new SlowBuffer or FastBuffer. Because of this, there are optimizations that
> cannot be performed by the v8 compiler. Even calls to 'this.parent.*' can't
> be optimized well since they require a 'context change' (which could be
> helped by placing the calls directly on the Buffer instance). For these and
> stability reasons (ability to internally manage 'offset's and the like) I
> propose that the memory allocation and management of Slow/Fast Buffers be
> moved to C land.
>
> The basics right now would be to:
> - Internally track memory pointers for FastBuffers.
> - 'parent' would no longer exists in userland.
> - Key user facing properties (e.g. length) are made read-only.
>
> There would be no changes to the documented API. Just, hopefully, making
> Buffers a little quicker and more predictable.

I'm okay with that, with the caveat that there should be no
performance or behavior regressions whatsoever.  That means writing a
lot of tests and benchmarks. :-)

-- 
Job Board: http://jobs.nodejs.org/
Posting guidelines: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to nodejs@googlegroups.com
To unsubscribe from this group, send email to
nodejs+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en

Reply via email to