Skip to content
This repository has been archived by the owner on Apr 22, 2023. It is now read-only.

Commit

Permalink
buffer: remove minor Buffer::Copy deoptimizations
Browse files Browse the repository at this point in the history
* Omit ToObject() call. Buffer::Data() and Buffer::Length() know how
  to deal with Values.

* Don't check if the argument is undefined because it realistically
  never is and undefined->integer coercion achieves the same thing.
  • Loading branch information
bnoordhuis committed Jan 25, 2013
1 parent cbe3941 commit 00b4b7b
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions src/node_buffer.cc
Expand Up @@ -398,13 +398,12 @@ Handle<Value> Buffer::Copy(const Arguments &args) {
return ThrowTypeError("First arg should be a Buffer");
}

Local<Object> target = args[0]->ToObject();
Local<Value> target = args[0];
char* target_data = Buffer::Data(target);
size_t target_length = Buffer::Length(target);
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();
size_t target_start = args[1]->Uint32Value();
size_t source_start = args[2]->Uint32Value();
size_t source_end = args[3]->Uint32Value();

if (source_end < source_start) {
return ThrowRangeError("sourceEnd < sourceStart");
Expand Down

1 comment on commit 00b4b7b

@isaacs
Copy link

@isaacs isaacs commented on 00b4b7b Jan 27, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This breaks test/simple/test-crypto.js

Please sign in to comment.