Skip to content

Commit a8b094c

Browse files
GauthamBanasandratargos
authored andcommitted
src: implement special member functions for classes in env.h
The classes in env.h were not adhering to the rule of five. As per the rule of five, if a class implements any of five special member functions, it must implement all the five special member functions for enabling the compiler for better optimization. Refs: https://en.cppreference.com/w/cpp/language/rule_of_three PR-URL: #28579 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com>
1 parent c432ab1 commit a8b094c

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

src/env.h

+30
Original file line numberDiff line numberDiff line change
@@ -462,6 +462,8 @@ class IsolateData : public MemoryRetainer {
462462
inline v8::Isolate* isolate() const;
463463
IsolateData(const IsolateData&) = delete;
464464
IsolateData& operator=(const IsolateData&) = delete;
465+
IsolateData(IsolateData&&) = delete;
466+
IsolateData& operator=(IsolateData&&) = delete;
465467

466468
private:
467469
void DeserializeProperties(const std::vector<size_t>* indexes);
@@ -552,6 +554,12 @@ class AsyncRequest : public MemoryRetainer {
552554
public:
553555
AsyncRequest() = default;
554556
~AsyncRequest();
557+
558+
AsyncRequest(const AsyncRequest&) = delete;
559+
AsyncRequest& operator=(const AsyncRequest&) = delete;
560+
AsyncRequest(AsyncRequest&&) = delete;
561+
AsyncRequest& operator=(AsyncRequest&&) = delete;
562+
555563
void Install(Environment* env, void* data, uv_async_cb target);
556564
void Uninstall();
557565
void Stop();
@@ -636,6 +644,9 @@ class AsyncHooks : public MemoryRetainer {
636644

637645
AsyncHooks(const AsyncHooks&) = delete;
638646
AsyncHooks& operator=(const AsyncHooks&) = delete;
647+
AsyncHooks(AsyncHooks&&) = delete;
648+
AsyncHooks& operator=(AsyncHooks&&) = delete;
649+
~AsyncHooks() = default;
639650

640651
// Used to set the kDefaultTriggerAsyncId in a scope. This is instead of
641652
// passing the trigger_async_id along with other constructor arguments.
@@ -650,6 +661,9 @@ class AsyncHooks : public MemoryRetainer {
650661
DefaultTriggerAsyncIdScope(const DefaultTriggerAsyncIdScope&) = delete;
651662
DefaultTriggerAsyncIdScope& operator=(const DefaultTriggerAsyncIdScope&) =
652663
delete;
664+
DefaultTriggerAsyncIdScope(DefaultTriggerAsyncIdScope&&) = delete;
665+
DefaultTriggerAsyncIdScope& operator=(DefaultTriggerAsyncIdScope&&) =
666+
delete;
653667

654668
private:
655669
AsyncHooks* async_hooks_;
@@ -679,6 +693,8 @@ class AsyncCallbackScope {
679693
~AsyncCallbackScope();
680694
AsyncCallbackScope(const AsyncCallbackScope&) = delete;
681695
AsyncCallbackScope& operator=(const AsyncCallbackScope&) = delete;
696+
AsyncCallbackScope(AsyncCallbackScope&&) = delete;
697+
AsyncCallbackScope& operator=(AsyncCallbackScope&&) = delete;
682698

683699
private:
684700
Environment* env_;
@@ -697,6 +713,9 @@ class ImmediateInfo : public MemoryRetainer {
697713

698714
ImmediateInfo(const ImmediateInfo&) = delete;
699715
ImmediateInfo& operator=(const ImmediateInfo&) = delete;
716+
ImmediateInfo(ImmediateInfo&&) = delete;
717+
ImmediateInfo& operator=(ImmediateInfo&&) = delete;
718+
~ImmediateInfo() = default;
700719

701720
SET_MEMORY_INFO_NAME(ImmediateInfo)
702721
SET_SELF_SIZE(ImmediateInfo)
@@ -723,6 +742,9 @@ class TickInfo : public MemoryRetainer {
723742

724743
TickInfo(const TickInfo&) = delete;
725744
TickInfo& operator=(const TickInfo&) = delete;
745+
TickInfo(TickInfo&&) = delete;
746+
TickInfo& operator=(TickInfo&&) = delete;
747+
~TickInfo() = default;
726748

727749
private:
728750
friend class Environment; // So we can call the constructor.
@@ -757,6 +779,12 @@ class ShouldNotAbortOnUncaughtScope {
757779
explicit inline ShouldNotAbortOnUncaughtScope(Environment* env);
758780
inline void Close();
759781
inline ~ShouldNotAbortOnUncaughtScope();
782+
ShouldNotAbortOnUncaughtScope(const ShouldNotAbortOnUncaughtScope&) = delete;
783+
ShouldNotAbortOnUncaughtScope& operator=(
784+
const ShouldNotAbortOnUncaughtScope&) = delete;
785+
ShouldNotAbortOnUncaughtScope(ShouldNotAbortOnUncaughtScope&&) = delete;
786+
ShouldNotAbortOnUncaughtScope& operator=(ShouldNotAbortOnUncaughtScope&&) =
787+
delete;
760788

761789
private:
762790
Environment* env_;
@@ -796,6 +824,8 @@ class Environment : public MemoryRetainer {
796824
public:
797825
Environment(const Environment&) = delete;
798826
Environment& operator=(const Environment&) = delete;
827+
Environment(Environment&&) = delete;
828+
Environment& operator=(Environment&&) = delete;
799829

800830
SET_MEMORY_INFO_NAME(Environment)
801831

0 commit comments

Comments
 (0)