refactor: use std::optional in MicrotasksScope (#43621)

avoid an unnecessary heap allocation/free
This commit is contained in:
Charles Kerr 2024-09-09 11:51:42 -05:00 committed by GitHub
parent e2fe8f50e2
commit 2844e346b9
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 3 additions and 4 deletions

View file

@ -5,7 +5,7 @@
#ifndef ELECTRON_SHELL_COMMON_GIN_HELPER_MICROTASKS_SCOPE_H_
#define ELECTRON_SHELL_COMMON_GIN_HELPER_MICROTASKS_SCOPE_H_
#include <memory>
#include <optional>
#include "v8/include/v8-forward.h"
#include "v8/include/v8-microtask-queue.h"
@ -27,7 +27,7 @@ class MicrotasksScope {
MicrotasksScope& operator=(const MicrotasksScope&) = delete;
private:
std::unique_ptr<v8::MicrotasksScope> v8_microtasks_scope_;
std::optional<v8::MicrotasksScope> v8_microtasks_scope_;
};
} // namespace gin_helper