diff options
author | Ben Noordhuis <info@bnoordhuis.nl> | 2014-10-11 16:24:12 +0200 |
---|---|---|
committer | Fedor Indutny <fedor@indutny.com> | 2014-10-12 02:09:16 +0400 |
commit | 97585b0d7ab0084d90faf6bded275b902d76857a (patch) | |
tree | 26853d875786c014e2e9ef5ed2ec18f7ed601775 /src/tcp_wrap.cc | |
parent | b2e519983f1e92a874a74c11e82027955ef8909a (diff) | |
download | android-node-v8-97585b0d7ab0084d90faf6bded275b902d76857a.tar.gz android-node-v8-97585b0d7ab0084d90faf6bded275b902d76857a.tar.bz2 android-node-v8-97585b0d7ab0084d90faf6bded275b902d76857a.zip |
src: remove unnecessary HandleScopes
API callback functions don't need to create a v8::HandleScope instance
because V8 already creates one in the JS->C++ adapter frame.
PR-URL: https://github.com/node-forward/node/pull/16
Reviewed-By: Fedor Indutny <fedor@indutny.com>
Diffstat (limited to 'src/tcp_wrap.cc')
-rw-r--r-- | src/tcp_wrap.cc | 36 |
1 files changed, 0 insertions, 36 deletions
diff --git a/src/tcp_wrap.cc b/src/tcp_wrap.cc index 09671d0095..13ec66f9a2 100644 --- a/src/tcp_wrap.cc +++ b/src/tcp_wrap.cc @@ -148,7 +148,6 @@ void TCPWrap::New(const FunctionCallbackInfo<Value>& args) { // Therefore we assert that we are not trying to call this as a // normal function. assert(args.IsConstructCall()); - HandleScope handle_scope(args.GetIsolate()); Environment* env = Environment::GetCurrent(args.GetIsolate()); TCPWrap* wrap = new TCPWrap(env, args.This()); assert(wrap); @@ -173,7 +172,6 @@ TCPWrap::~TCPWrap() { void TCPWrap::GetSockName(const FunctionCallbackInfo<Value>& args) { - HandleScope handle_scope(args.GetIsolate()); Environment* env = Environment::GetCurrent(args.GetIsolate()); struct sockaddr_storage address; @@ -196,7 +194,6 @@ void TCPWrap::GetSockName(const FunctionCallbackInfo<Value>& args) { void TCPWrap::GetPeerName(const FunctionCallbackInfo<Value>& args) { - HandleScope handle_scope(args.GetIsolate()); Environment* env = Environment::GetCurrent(args.GetIsolate()); struct sockaddr_storage address; @@ -219,11 +216,7 @@ void TCPWrap::GetPeerName(const FunctionCallbackInfo<Value>& args) { void TCPWrap::SetNoDelay(const FunctionCallbackInfo<Value>& args) { - Environment* env = Environment::GetCurrent(args.GetIsolate()); - HandleScope scope(env->isolate()); - TCPWrap* wrap = Unwrap<TCPWrap>(args.Holder()); - int enable = static_cast<int>(args[0]->BooleanValue()); int err = uv_tcp_nodelay(&wrap->handle_, enable); args.GetReturnValue().Set(err); @@ -231,14 +224,9 @@ void TCPWrap::SetNoDelay(const FunctionCallbackInfo<Value>& args) { void TCPWrap::SetKeepAlive(const FunctionCallbackInfo<Value>& args) { - Environment* env = Environment::GetCurrent(args.GetIsolate()); - HandleScope scope(env->isolate()); - TCPWrap* wrap = Unwrap<TCPWrap>(args.Holder()); - int enable = args[0]->Int32Value(); unsigned int delay = args[1]->Uint32Value(); - int err = uv_tcp_keepalive(&wrap->handle_, enable, delay); args.GetReturnValue().Set(err); } @@ -246,11 +234,7 @@ void TCPWrap::SetKeepAlive(const FunctionCallbackInfo<Value>& args) { #ifdef _WIN32 void TCPWrap::SetSimultaneousAccepts(const FunctionCallbackInfo<Value>& args) { - Environment* env = Environment::GetCurrent(args.GetIsolate()); - HandleScope scope(env->isolate()); - TCPWrap* wrap = Unwrap<TCPWrap>(args.Holder()); - bool enable = args[0]->BooleanValue(); int err = uv_tcp_simultaneous_accepts(&wrap->handle_, enable); args.GetReturnValue().Set(err); @@ -259,8 +243,6 @@ void TCPWrap::SetSimultaneousAccepts(const FunctionCallbackInfo<Value>& args) { void TCPWrap::Open(const FunctionCallbackInfo<Value>& args) { - Environment* env = Environment::GetCurrent(args.GetIsolate()); - HandleScope scope(env->isolate()); TCPWrap* wrap = Unwrap<TCPWrap>(args.Holder()); int fd = static_cast<int>(args[0]->IntegerValue()); uv_tcp_open(&wrap->handle_, fd); @@ -268,14 +250,9 @@ void TCPWrap::Open(const FunctionCallbackInfo<Value>& args) { void TCPWrap::Bind(const FunctionCallbackInfo<Value>& args) { - Environment* env = Environment::GetCurrent(args.GetIsolate()); - HandleScope scope(env->isolate()); - TCPWrap* wrap = Unwrap<TCPWrap>(args.Holder()); - node::Utf8Value ip_address(args[0]); int port = args[1]->Int32Value(); - sockaddr_in addr; int err = uv_ip4_addr(*ip_address, port, &addr); if (err == 0) { @@ -283,20 +260,14 @@ void TCPWrap::Bind(const FunctionCallbackInfo<Value>& args) { reinterpret_cast<const sockaddr*>(&addr), 0); } - args.GetReturnValue().Set(err); } void TCPWrap::Bind6(const FunctionCallbackInfo<Value>& args) { - Environment* env = Environment::GetCurrent(args.GetIsolate()); - HandleScope scope(env->isolate()); - TCPWrap* wrap = Unwrap<TCPWrap>(args.Holder()); - node::Utf8Value ip6_address(args[0]); int port = args[1]->Int32Value(); - sockaddr_in6 addr; int err = uv_ip6_addr(*ip6_address, port, &addr); if (err == 0) { @@ -304,17 +275,12 @@ void TCPWrap::Bind6(const FunctionCallbackInfo<Value>& args) { reinterpret_cast<const sockaddr*>(&addr), 0); } - args.GetReturnValue().Set(err); } void TCPWrap::Listen(const FunctionCallbackInfo<Value>& args) { - Environment* env = Environment::GetCurrent(args.GetIsolate()); - HandleScope scope(env->isolate()); - TCPWrap* wrap = Unwrap<TCPWrap>(args.Holder()); - int backlog = args[0]->Int32Value(); int err = uv_listen(reinterpret_cast<uv_stream_t*>(&wrap->handle_), backlog, @@ -387,7 +353,6 @@ void TCPWrap::AfterConnect(uv_connect_t* req, int status) { void TCPWrap::Connect(const FunctionCallbackInfo<Value>& args) { - HandleScope handle_scope(args.GetIsolate()); Environment* env = Environment::GetCurrent(args.GetIsolate()); TCPWrap* wrap = Unwrap<TCPWrap>(args.Holder()); @@ -421,7 +386,6 @@ void TCPWrap::Connect(const FunctionCallbackInfo<Value>& args) { void TCPWrap::Connect6(const FunctionCallbackInfo<Value>& args) { - HandleScope handle_scope(args.GetIsolate()); Environment* env = Environment::GetCurrent(args.GetIsolate()); TCPWrap* wrap = Unwrap<TCPWrap>(args.Holder()); |