Skip to content

Commit d402481

Browse files
committed
src: remove unnecessary Reset() calls
The previous commit made persistent handles auto-reset on destruction. This commit removes the Reset() calls that are now no longer necessary. PR-URL: #18656 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Joyee Cheung <[email protected]>
1 parent 992703f commit d402481

23 files changed

+2
-101
lines changed

src/async_wrap.cc

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -425,8 +425,6 @@ void AsyncWrap::WeakCallback(const v8::WeakCallbackInfo<DestroyParam>& info) {
425425
if (val->IsFalse()) {
426426
AsyncWrap::EmitDestroy(env, p->asyncId);
427427
}
428-
p->target.Reset();
429-
p->propBag.Reset();
430428
delete p;
431429
}
432430

src/base_object-inl.h

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,6 @@ inline BaseObject::BaseObject(Environment* env, v8::Local<v8::Object> handle)
4242
}
4343

4444

45-
inline BaseObject::~BaseObject() {
46-
CHECK(persistent_handle_.IsEmpty());
47-
}
48-
49-
5045
inline Persistent<v8::Object>& BaseObject::persistent() {
5146
return persistent_handle_;
5247
}
@@ -65,8 +60,7 @@ inline Environment* BaseObject::env() const {
6560
template <typename Type>
6661
inline void BaseObject::WeakCallback(
6762
const v8::WeakCallbackInfo<Type>& data) {
68-
std::unique_ptr<Type> self(data.GetParameter());
69-
self->persistent().Reset();
63+
delete data.GetParameter();
7064
}
7165

7266

src/base_object.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ class Environment;
3434
class BaseObject {
3535
public:
3636
inline BaseObject(Environment* env, v8::Local<v8::Object> handle);
37-
inline virtual ~BaseObject();
37+
virtual ~BaseObject() = default;
3838

3939
// Returns the wrapped object. Returns an empty handle when
4040
// persistent.IsEmpty() is true.

src/cares_wrap.cc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -598,7 +598,6 @@ class QueryWrap : public AsyncWrap {
598598
~QueryWrap() override {
599599
CHECK_EQ(false, persistent().IsEmpty());
600600
ClearWrap(object());
601-
persistent().Reset();
602601
}
603602

604603
// Subclasses should implement the appropriate Send method.

src/env-inl.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -370,9 +370,6 @@ inline Environment::~Environment() {
370370

371371
context()->SetAlignedPointerInEmbedderData(kContextEmbedderDataIndex,
372372
nullptr);
373-
#define V(PropertyName, TypeName) PropertyName ## _.Reset();
374-
ENVIRONMENT_STRONG_PERSISTENT_PROPERTIES(V)
375-
#undef V
376373

377374
delete[] heap_statistics_buffer_;
378375
delete[] heap_space_statistics_buffer_;

src/env.cc

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -314,8 +314,6 @@ void Environment::RunAndClearNativeImmediates() {
314314
v8::TryCatch try_catch(isolate());
315315
for (auto it = list.begin(); it != list.end(); ++it) {
316316
it->cb_(this, it->data_);
317-
if (it->keep_alive_)
318-
it->keep_alive_->Reset();
319317
if (it->refed_)
320318
ref_count++;
321319
if (UNLIKELY(try_catch.HasCaught())) {

src/handle_wrap.cc

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -98,11 +98,6 @@ HandleWrap::HandleWrap(Environment* env,
9898
}
9999

100100

101-
HandleWrap::~HandleWrap() {
102-
CHECK(persistent().IsEmpty());
103-
}
104-
105-
106101
void HandleWrap::OnClose(uv_handle_t* handle) {
107102
HandleWrap* wrap = static_cast<HandleWrap*>(handle->data);
108103
Environment* env = wrap->env();
@@ -120,7 +115,6 @@ void HandleWrap::OnClose(uv_handle_t* handle) {
120115
wrap->MakeCallback(env->onclose_string(), 0, nullptr);
121116

122117
ClearWrap(wrap->object());
123-
wrap->persistent().Reset();
124118
delete wrap;
125119
}
126120

src/handle_wrap.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,6 @@ class HandleWrap : public AsyncWrap {
7575
v8::Local<v8::Object> object,
7676
uv_handle_t* handle,
7777
AsyncWrap::ProviderType provider);
78-
~HandleWrap() override;
7978

8079
private:
8180
friend class Environment;

src/inspector_js_api.cc

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -84,10 +84,6 @@ class JSBindingsConnection : public AsyncWrap {
8484
inspector->Connect(&delegate_);
8585
}
8686

87-
~JSBindingsConnection() override {
88-
callback_.Reset();
89-
}
90-
9187
void OnMessage(Local<Value> value) {
9288
MakeCallback(callback_.Get(env()->isolate()), 1, &value);
9389
}
@@ -111,7 +107,6 @@ class JSBindingsConnection : public AsyncWrap {
111107
delegate_.Disconnect();
112108
if (!persistent().IsEmpty()) {
113109
ClearWrap(object());
114-
persistent().Reset();
115110
}
116111
delete this;
117112
}

src/module_wrap.cc

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,6 @@ ModuleWrap::~ModuleWrap() {
6060
break;
6161
}
6262
}
63-
64-
module_.Reset();
65-
context_.Reset();
6663
}
6764

6865
ModuleWrap* ModuleWrap::GetFromModule(Environment* env,
@@ -227,8 +224,6 @@ void ModuleWrap::Instantiate(const FunctionCallbackInfo<Value>& args) {
227224
module->InstantiateModule(context, ModuleWrap::ResolveCallback);
228225

229226
// clear resolve cache on instantiate
230-
for (auto& entry : obj->resolve_cache_)
231-
entry.second.Reset();
232227
obj->resolve_cache_.clear();
233228

234229
if (!ok.FromMaybe(false)) {

0 commit comments

Comments
 (0)