aboutsummaryrefslogtreecommitdiff
path: root/src/node_buffer.cc
diff options
context:
space:
mode:
authorTrevor Norris <trev.norris@gmail.com>2013-01-22 09:09:12 -0800
committerBen Noordhuis <info@bnoordhuis.nl>2013-01-25 11:58:51 +0100
commit16bbeccd40a9d08f7ae73eeeefa0fd6f206dc7a9 (patch)
treee1f3f822120ed676105505b7c27b85f55b6e86e6 /src/node_buffer.cc
parent83154aa15db01f46c7f59744bd8f65ca570ac397 (diff)
downloadandroid-node-v8-16bbeccd40a9d08f7ae73eeeefa0fd6f206dc7a9.tar.gz
android-node-v8-16bbeccd40a9d08f7ae73eeeefa0fd6f206dc7a9.tar.bz2
android-node-v8-16bbeccd40a9d08f7ae73eeeefa0fd6f206dc7a9.zip
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.
Diffstat (limited to 'src/node_buffer.cc')
-rw-r--r--src/node_buffer.cc8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/node_buffer.cc b/src/node_buffer.cc
index 70c9c80876..d808dbf978 100644
--- a/src/node_buffer.cc
+++ b/src/node_buffer.cc
@@ -402,10 +402,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(