Prompt
Embrace modern C++20 features throughout the codebase to improve code readability, maintainability, and performance. Specifically:
- Use condensed namespace syntax:
// Preferred namespace node::inspector::protocol { // ... } // Instead of namespace node { namespace inspector { namespace protocol { // ... } } } - Prefer
std::string_viewoverconst std::string&for parameters that don’t need ownership:// Preferred const auto function = [](std::string_view path) { // Use path directly without copying }; // Instead of const auto function = [](const std::string& path) { // Potentially causes unnecessary copies }; - Use
enum classfor better type safety and scope control:// Preferred enum class Mode { Shared, Exclusive }; // Instead of enum Mode { kShared, kExclusive }; - Properly manage v8::Global objects using move semantics and reset():
// Preferred v8::Global<v8::Promise::Resolver> holder(isolate, resolver); // When done: holder.reset(); // Instead of auto* holder = new v8::Global<v8::Promise::Resolver>(isolate, resolver); // When done: delete holder;