mirror of https://github.com/nodejs/node.git
buffer: remove minor Buffer::Copy deoptimizations
* 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.pull/24504/head
parent
cbe3941db9
commit
00b4b7bb97
|
@ -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");
|
||||
|
|
Loading…
Reference in New Issue