Skip to content

Instantly share code, notes, and snippets.

@indutny

indutny/1.patch Secret

Created April 28, 2013 21:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save indutny/44586daf809530f8b6f0 to your computer and use it in GitHub Desktop.
Save indutny/44586daf809530f8b6f0 to your computer and use it in GitHub Desktop.
diff --git a/src/node_http_parser.cc b/src/node_http_parser.cc
index 782bdf9..6747409 100644
--- a/src/node_http_parser.cc
+++ b/src/node_http_parser.cc
@@ -243,7 +243,8 @@ public:
HTTP_CB(on_headers_complete) {
- Local<Value> cb = handle_->Get(on_headers_complete_sym);
+ static Object::CachedProperty prop(on_headers_complete_sym);
+ Local<Value> cb = handle_->Get(prop);
if (!cb->IsFunction())
return 0;
@@ -304,7 +305,8 @@ public:
HTTP_DATA_CB(on_body) {
HandleScope scope(node_isolate);
- Local<Value> cb = handle_->Get(on_body_sym);
+ static Object::CachedProperty prop(on_body_sym);
+ Local<Value> cb = handle_->Get(prop);
if (!cb->IsFunction())
return 0;
@@ -331,7 +333,8 @@ public:
if (num_fields_)
Flush(); // Flush trailing HTTP headers.
- Local<Value> cb = handle_->Get(on_message_complete_sym);
+ static Object::CachedProperty prop(on_message_complete_sym);
+ Local<Value> cb = handle_->Get(prop);
if (!cb->IsFunction())
return 0;
@@ -515,7 +518,8 @@ private:
void Flush() {
HandleScope scope(node_isolate);
- Local<Value> cb = handle_->Get(on_headers_sym);
+ static Object::CachedProperty prop(on_headers_sym);
+ Local<Value> cb = handle_->Get(prop);
if (!cb->IsFunction())
return;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment