Skip to content

Commit f89f659

Browse files
bnoordhuisMylesBorins
authored andcommitted
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. Backport-PR-URL: #19185 PR-URL: #18656 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
1 parent 67a9742 commit f89f659

22 files changed

+2
-100
lines changed

src/async_wrap.cc

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

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
@@ -357,9 +357,6 @@ inline Environment::~Environment() {
357357

358358
context()->SetAlignedPointerInEmbedderData(kContextEmbedderDataIndex,
359359
nullptr);
360-
#define V(PropertyName, TypeName) PropertyName ## _.Reset();
361-
ENVIRONMENT_STRONG_PERSISTENT_PROPERTIES(V)
362-
#undef V
363360

364361
delete[] heap_statistics_buffer_;
365362
delete[] heap_space_statistics_buffer_;

src/env.cc

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -300,8 +300,6 @@ void Environment::RunAndClearNativeImmediates() {
300300
v8::TryCatch try_catch(isolate());
301301
for (auto it = list.begin(); it != list.end(); ++it) {
302302
it->cb_(this, it->data_);
303-
if (it->keep_alive_)
304-
it->keep_alive_->Reset();
305303
if (it->refed_)
306304
ref_count++;
307305
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
@@ -59,9 +59,6 @@ ModuleWrap::~ModuleWrap() {
5959
break;
6060
}
6161
}
62-
63-
module_.Reset();
64-
context_.Reset();
6562
}
6663

6764
void ModuleWrap::New(const FunctionCallbackInfo<Value>& args) {
@@ -215,8 +212,6 @@ void ModuleWrap::Instantiate(const FunctionCallbackInfo<Value>& args) {
215212
module->InstantiateModule(context, ModuleWrap::ResolveCallback);
216213

217214
// clear resolve cache on instantiate
218-
for (auto& entry : obj->resolve_cache_)
219-
entry.second.Reset();
220215
obj->resolve_cache_.clear();
221216

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

0 commit comments

Comments
 (0)