mirror of
https://github.com/nodejs/node-v0.x-archive.git
synced 2026-04-28 03:01:10 -04:00
buffer: slow buffer copy compatibility fix
Fix issue where SlowBuffers couldn't be passed as target to Buffer
copy().
Also included checks to see if Argument parameters are defined before
assigning their values. This offered ~3x's performance gain.
Backport of 16bbecc from master branch. Closes #4633.
This commit is contained in:
committed by
Nathan Rajlich
parent
72dd3b4e25
commit
65249ccd9b
@@ -412,10 +412,10 @@ Handle<Value> Buffer::Copy(const Arguments &args) {
|
||||
Local<Object> target = args[0]->ToObject();
|
||||
char* target_data = Buffer::Data(target);
|
||||
size_t target_length = Buffer::Length(target);
|
||||
size_t target_start = args[1]->Uint32Value();
|
||||
size_t source_start = args[2]->Uint32Value();
|
||||
size_t source_end = args[3]->IsUint32() ? args[3]->Uint32Value()
|
||||
: source->length_;
|
||||
size_t target_start = args[1]->IsUndefined() ? 0 : args[1]->Uint32Value();
|
||||
size_t source_start = args[2]->IsUndefined() ? 0 : args[2]->Uint32Value();
|
||||
size_t source_end = args[3]->IsUndefined() ? source->length_
|
||||
: args[3]->Uint32Value();
|
||||
|
||||
if (source_end < source_start) {
|
||||
return ThrowException(Exception::Error(String::New(
|
||||
|
||||
Reference in New Issue
Block a user