From 00b4b7bb97c84d19c644a4491fe98170ab9675a6 Mon Sep 17 00:00:00 2001 From: Ben Noordhuis Date: Fri, 25 Jan 2013 22:03:11 +0100 Subject: [PATCH] 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. --- src/node_buffer.cc | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/node_buffer.cc b/src/node_buffer.cc index 85fa5cfe234..2fa7e89952d 100644 --- a/src/node_buffer.cc +++ b/src/node_buffer.cc @@ -398,13 +398,12 @@ Handle Buffer::Copy(const Arguments &args) { return ThrowTypeError("First arg should be a Buffer"); } - Local target = args[0]->ToObject(); + Local 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");