mirror of
https://github.com/nodejs/node-v0.x-archive.git
synced 2026-04-28 03:01:10 -04:00
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.
This commit is contained in:
@@ -398,13 +398,12 @@ Handle<Value> Buffer::Copy(const Arguments &args) {
|
|||||||
return ThrowTypeError("First arg should be a Buffer");
|
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);
|
char* target_data = Buffer::Data(target);
|
||||||
size_t target_length = Buffer::Length(target);
|
size_t target_length = Buffer::Length(target);
|
||||||
size_t target_start = args[1]->IsUndefined() ? 0 : args[1]->Uint32Value();
|
size_t target_start = args[1]->Uint32Value();
|
||||||
size_t source_start = args[2]->IsUndefined() ? 0 : args[2]->Uint32Value();
|
size_t source_start = args[2]->Uint32Value();
|
||||||
size_t source_end = args[3]->IsUndefined() ? source->length_
|
size_t source_end = args[3]->Uint32Value();
|
||||||
: args[3]->Uint32Value();
|
|
||||||
|
|
||||||
if (source_end < source_start) {
|
if (source_end < source_start) {
|
||||||
return ThrowRangeError("sourceEnd < sourceStart");
|
return ThrowRangeError("sourceEnd < sourceStart");
|
||||||
|
|||||||
Reference in New Issue
Block a user