Repository: electron/electron
Pull request: perf: avoid redundant method calls in EventEmitter

#### Description of Change

Some cleanup to `gin_helper::EventEmitter`:

- avoid redundant calls to `gin_helper::Wrappable<T>::GetWrapper()`
- remove unused method `EventEmitter<T>::isolate()`
- remove unused method `EventEmitter<T>::GetWrapper()`
- remove unused method `EventEmitter<T>::GetWrapper(v8::Isolate*)`
- remove unused typedef `EventEmitter::Base`

#### Checklist

- [x] PR description included and stakeholders cc'd
- [x] `npm test` passes
- [x] [PR release notes](https://github.com/electron/clerk/blob/main/README.md) describe the change in a way relevant to app developers, and are [capitalized, punctuated, and past tense](https://github.com/electron/clerk/blob/main/README.md#examples).

#### Release Notes

Notes: none

Changed files:
filename: shell/common/gin_helper/event_emitter.h
patch: @@ -23,37 +23,30 @@ namespace gin_helper {
 template <typename T>
 class EventEmitter : public gin_helper::Wrappable<T> {
  public:
-  using Base = gin_helper::Wrappable<T>;
-
-  // Make the convenient methods visible:
-  // https://isocpp.org/wiki/faq/templates#nondependent-name-lookup-members
-  v8::Isolate* isolate() const { return Base::isolate(); }
-  v8::Local<v8::Object> GetWrapper() const { return Base::GetWrapper(); }
-  v8::MaybeLocal<v8::Object> GetWrapper(v8::Isolate* isolate) const {
-    return Base::GetWrapper(isolate);
-  }
-
   // this.emit(name, new Event(), args...);
   template <typename... Args>
   bool Emit(const std::string_view name, Args&&... args) {
-    v8::HandleScope handle_scope(isolate());
-    v8::Local<v8::Object> wrapper = GetWrapper();
+    v8::Isolate* const isolate = this->isolate();
+    v8::HandleScope handle_scope{isolate};
+    v8::Local<v8::Object> wrapper = this->GetWrapper();
     if (wrapper.IsEmpty())
       return false;
-    gin::Handle<gin_helper::internal::Event> event =
-        internal::Event::New(isolate());
-    return EmitWithEvent(name, event, std::forward<Args>(args)...);
+    gin::Handle<internal::Event> event = internal::Event::New(isolate);
+    // It's possible that |this| will be deleted by EmitEvent, so save anything
+    // we need from |this| before calling EmitEvent.
+    EmitEvent(isolate, wrapper, name, event, std::forward<Args>(args)...);
+    return event->GetDefaultPrevented();
   }
 
   // this.emit(name, args...);
   template <typename... Args>
   void EmitWithoutEvent(const std::string_view name, Args&&... args) {
-    v8::HandleScope handle_scope(isolate());
-    v8::Local<v8::Object> wrapper = GetWrapper();
+    v8::Isolate* const isolate = this->isolate();
+    v8::HandleScope handle_scope{isolate};
+    v8::Local<v8::Object> wrapper = this->GetWrapper();
     if (wrapper.IsEmpty())
       return;
-    gin_helper::EmitEvent(isolate(), GetWrapper(), name,
-                          std::forward<Args>(args)...);
+    EmitEvent(isolate, wrapper, name, std::forward<Args>(args)...);
   }
 
   // disable copy
@@ -62,20 +55,6 @@ class EventEmitter : public gin_helper::Wrappable<T> {
 
  protected:
   EventEmitter() = default;
-
- private:
-  // this.emit(name, event, args...);
-  template <typename... Args>
-  bool EmitWithEvent(const std::string_view name,
-                     gin::Handle<gin_helper::internal::Event> event,
-                     Args&&... args) {
-    // It's possible that |this| will be deleted by EmitEvent, so save anything
-    // we need from |this| before calling EmitEvent.
-    auto* isolate = this->isolate();
-    gin_helper::EmitEvent(isolate, GetWrapper(), name, event,
-                          std::forward<Args>(args)...);
-    return event->GetDefaultPrevented();
-  }
 };
 
 }  // namespace gin_helper