diff options
author | Ben Noordhuis <info@bnoordhuis.nl> | 2014-08-23 00:31:44 +0200 |
---|---|---|
committer | Trevor Norris <trev.norris@gmail.com> | 2014-09-05 09:34:15 -0700 |
commit | b33a47ef473c169be2f11a2ee434f0f89ea1d106 (patch) | |
tree | e8e200e9f32a0692df26cf594003219ace933077 /src/node_http_parser.cc | |
parent | 1e99486cc83d0e3c41de37c924150f2853870902 (diff) | |
download | android-node-v8-b33a47ef473c169be2f11a2ee434f0f89ea1d106.tar.gz android-node-v8-b33a47ef473c169be2f11a2ee434f0f89ea1d106.tar.bz2 android-node-v8-b33a47ef473c169be2f11a2ee434f0f89ea1d106.zip |
lib, src: don't make http parser handles weak
Weak handles put strain on the garbage collector and the parser handle
doesn't need to be weak in the first place. This change should improve
GC times on busy servers a little.
Reviewed-by: Trevor Norris <trev.norris@gmail.com>
Diffstat (limited to 'src/node_http_parser.cc')
-rw-r--r-- | src/node_http_parser.cc | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/src/node_http_parser.cc b/src/node_http_parser.cc index 04b86097ef..8d9b66ed06 100644 --- a/src/node_http_parser.cc +++ b/src/node_http_parser.cc @@ -169,12 +169,14 @@ class Parser : public BaseObject { : BaseObject(env, wrap), current_buffer_len_(0), current_buffer_data_(NULL) { - MakeWeak<Parser>(this); + Wrap(object(), this); Init(type); } ~Parser() { + ClearWrap(object()); + persistent().Reset(); } @@ -357,6 +359,13 @@ class Parser : public BaseObject { } + static void Close(const FunctionCallbackInfo<Value>& args) { + HandleScope handle_scope(args.GetIsolate()); + Parser* parser = Unwrap<Parser>(args.Holder()); + delete parser; + } + + void Save() { url_.Save(); status_message_.Save(); @@ -591,6 +600,7 @@ void InitHttpParser(Handle<Object> target, #undef V t->Set(FIXED_ONE_BYTE_STRING(env->isolate(), "methods"), methods); + NODE_SET_PROTOTYPE_METHOD(t, "close", Parser::Close); NODE_SET_PROTOTYPE_METHOD(t, "execute", Parser::Execute); NODE_SET_PROTOTYPE_METHOD(t, "finish", Parser::Finish); NODE_SET_PROTOTYPE_METHOD(t, "reinitialize", Parser::Reinitialize); |