If performance is really key (more so than memory usage) you might
consider allocating a nice big buffer to put data into as you receive
it rather than allocating and concatenating a whole bunch of smaller
buffers.


On Feb 29, 8:32 am, billywhizz <[email protected]> wrote:
> ok. understood. anyone know the fastest way to concatenate multiple
> buffers into a single buffer? i need to concatenate multiple binary
> buffers into one binary buffer when doing a file upload. the only way
> i can think of is to do the following:
>
> 1) as the buffers arrive in, push them into an array. when the upload
> is complete, calculate the total size from the array, create a new
> buffer of that size and do a buffer.copy of each array element into
> the new buffer
> 2) pre-allocate a buffer of a certain size and as each buffer arrives
> in, do a buffer.copy into this buffer, keeping track of the offset so
> we know the number of bytes to slice when the upload is complete.
> obviously would need to ensure the buffer being copied into will be
> big enough to hold everything
>
> On Feb 29, 12:10 am, Mark Hahn <[email protected]> wrote:
>
>
>
>
>
>
>
> > It is not a default method.  The plus sign coerces anything other than all
> > numbers into strings.

-- 
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 [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en

Reply via email to