зеркало из https://github.com/electron/electron.git
refactor: use std::optional in MicrotasksScope (#43621)
avoid an unnecessary heap allocation/free
This commit is contained in:
Родитель
e2fe8f50e2
Коммит
2844e346b9
|
@ -16,8 +16,7 @@ MicrotasksScope::MicrotasksScope(v8::Isolate* isolate,
|
|||
if (!ignore_browser_checkpoint)
|
||||
v8::MicrotasksScope::PerformCheckpoint(isolate);
|
||||
} else {
|
||||
v8_microtasks_scope_ = std::make_unique<v8::MicrotasksScope>(
|
||||
isolate, microtask_queue, scope_type);
|
||||
v8_microtasks_scope_.emplace(isolate, microtask_queue, scope_type);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
Загрузка…
Ссылка в новой задаче