Skip to content

Commit f22d98a

Browse files
committed
improved code stench
1 parent ea1175c commit f22d98a

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

src/addon.cpp

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,12 @@
44
#include <node_object_wrap.h>
55

66
struct Addon {
7-
v8::Persistent<v8::Function> constructor;
8-
v8::Persistent<v8::FunctionTemplate> constructorTemplate;
7+
CopyablePersistent<v8::Function> constructor;
8+
CopyablePersistent<v8::FunctionTemplate> constructorTemplate;
99
struct { bool privileges; int64_t value; } controller;
1010

1111
static void Cleanup(void* ptr) {
12-
Addon* addon = static_cast<Addon*>(ptr);
13-
addon->constructor.Reset();
14-
addon->constructorTemplate.Reset();
15-
delete addon;
12+
delete static_cast<Addon*>(ptr);
1613
}
1714
};
1815

src/macros.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,3 +101,7 @@ void SetPrototypeGetter(
101101
v8::AccessorSignature::New(isolate, recv)
102102
);
103103
}
104+
105+
#hdr
106+
template <class T> using CopyablePersistent = v8::Persistent<T, v8::CopyablePersistentTraits<T>>;
107+
#end

0 commit comments

Comments
 (0)