diff options
| author | Trevor Norris <trev.norris@gmail.com> | 2013-08-16 11:32:56 -0700 |
|---|---|---|
| committer | Trevor Norris <trev.norris@gmail.com> | 2013-08-16 12:42:33 -0700 |
| commit | 2dd4a745b0ec5b5d44ee884d865b5094c63fe39a (patch) | |
| tree | cb1362f04e1ae41bdb7e8e7f93bf646cb9afcb35 /src/node_buffer.cc | |
| parent | ec548734cae52713432addacc6787b87f5c5051e (diff) | |
| download | node-2dd4a745b0ec5b5d44ee884d865b5094c63fe39a.tar.gz | |
buffer: don't call ByteLength for simple encodings
For several encodings the byte length is simple arithmetic. Don't call
into C++ in those cases.
Diffstat (limited to 'src/node_buffer.cc')
| -rw-r--r-- | src/node_buffer.cc | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/src/node_buffer.cc b/src/node_buffer.cc index b69ff63bf..1a9e12850 100644 --- a/src/node_buffer.cc +++ b/src/node_buffer.cc @@ -566,9 +566,6 @@ void SetupBufferJS(const FunctionCallbackInfo<Value>& args) { Local<Object> proto = proto_v.As<Object>(); - bv->Set(FIXED_ONE_BYTE_STRING(node_isolate, "byteLength"), - FunctionTemplate::New(ByteLength)->GetFunction()); - NODE_SET_METHOD(proto, "asciiSlice", AsciiSlice); NODE_SET_METHOD(proto, "base64Slice", Base64Slice); NODE_SET_METHOD(proto, "binarySlice", BinarySlice); @@ -600,6 +597,14 @@ void SetupBufferJS(const FunctionCallbackInfo<Value>& args) { proto->Set(FIXED_ONE_BYTE_STRING(node_isolate, "offset"), Uint32::New(0, node_isolate), v8::ReadOnly); + + assert(args[1]->IsObject()); + + Local<Object> internal = args[1].As<Object>(); + + internal->Set(FIXED_ONE_BYTE_STRING(node_isolate, "byteLength"), + FunctionTemplate::New(ByteLength)->GetFunction()); + } |
