| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -43,21 +43,21 @@ static bool ReallyEmit(Handle<Object> self, | |||
| 43 | 43 | Handle<String> event, | |
| 44 | 44 | int argc, | |
| 45 | 45 | Handle<Value> argv[]) { | |
| 46 | - HandleScope scope; | ||
| 47 | - | ||
| 46 | + // HandleScope not needed here because only called from one of the two | ||
| 47 | + // functions below | ||
| 48 | 48 | Local<Value> events_v = self->Get(events_symbol); | |
| 49 | 49 | if (!events_v->IsObject()) return false; | |
| 50 | 50 | Local<Object> events = events_v->ToObject(); | |
| 51 | 51 | ||
| 52 | 52 | Local<Value> listeners_v = events->Get(event); | |
| 53 | 53 | Local<Function> listener; | |
| 54 | 54 | ||
| 55 | + TryCatch try_catch; | ||
| 56 | + | ||
| 55 | 57 | if (listeners_v->IsFunction()) { | |
| 56 | 58 | // Optimized one-listener case | |
| 57 | 59 | Local<Function> listener = Local<Function>::Cast(listeners_v); | |
| 58 | 60 | ||
| 59 | - TryCatch try_catch; | ||
| 60 | - | ||
| 61 | 61 | listener->Call(self, argc, argv); | |
| 62 | 62 | ||
| 63 | 63 | if (try_catch.HasCaught()) { | |
@@ -68,15 +68,11 @@ static bool ReallyEmit(Handle<Object> self, | |||
| 68 | 68 | } else if (listeners_v->IsArray()) { | |
| 69 | 69 | Local<Array> listeners = Local<Array>::Cast(listeners_v); | |
| 70 | 70 | ||
| 71 | - for (unsigned int i = 0; i < listeners->Length(); i++) { | ||
| 72 | - HandleScope scope; | ||
| 73 | - | ||
| 74 | - Local<Value> listener_v = listeners->Get(Integer::New(i)); | ||
| 71 | + for (uint32_t i = 0; i < listeners->Length(); i++) { | ||
| 72 | + Local<Value> listener_v = listeners->Get(i); | ||
| 75 | 73 | if (!listener_v->IsFunction()) continue; | |
| 76 | 74 | Local<Function> listener = Local<Function>::Cast(listener_v); | |
| 77 | 75 | ||
| 78 | - TryCatch try_catch; | ||
| 79 | - | ||
| 80 | 76 | listener->Call(self, argc, argv); | |
| 81 | 77 | ||
| 82 | 78 | if (try_catch.HasCaught()) { | |
| Back | FazBrowse Home | New Git URL |
0 commit comments