@@ -84,8 +84,9 @@ template<typename T> class PersistentBase {
84
84
private:
85
85
NAN_INLINE PersistentBase () :
86
86
persistent() {}
87
- NAN_INLINE explicit PersistentBase (v8::Persistent<T> that) :
88
- persistent(v8::Isolate::GetCurrent(), that) { }
87
+ NAN_INLINE explicit PersistentBase (v8::Persistent<T> that) {
88
+ std::memcpy (&that, &persistent, sizeof (v8::Persistent<T>));
89
+ }
89
90
NAN_INLINE explicit PersistentBase (v8::Local<T> that) :
90
91
persistent(v8::Isolate::GetCurrent(), that) { }
91
92
template <typename S, typename M> friend class Persistent ;
@@ -181,12 +182,12 @@ class Global : public PersistentBase<T> {
181
182
182
183
template <class S >
183
184
NAN_INLINE Global (const PersistentBase<S>& that)
184
- : PersistentBase<T>(that) {
185
+ : PersistentBase<T>(v8::Persistent<T>(v8::Isolate::GetCurrent(), that.persistent) ) {
185
186
TYPE_CHECK (T, S);
186
187
}
187
188
188
189
NAN_INLINE Global (Global&& other) : PersistentBase<T>(other.persistent) {
189
- other.Reset ();
190
+ other.Empty ();
190
191
}
191
192
192
193
NAN_INLINE ~Global () { this ->Reset (); }
@@ -195,8 +196,8 @@ class Global : public PersistentBase<T> {
195
196
NAN_INLINE Global& operator =(Global<S>&& rhs) {
196
197
TYPE_CHECK (T, S);
197
198
if (this != &rhs) {
198
- this -> Reset ( rhs.persistent );
199
- rhs.Reset ();
199
+ std::memcpy (& rhs.persistent , & this -> persistent , sizeof (v8::PersistentBase<S>) );
200
+ rhs.Empty ();
200
201
}
201
202
return *this ;
202
203
}
@@ -226,16 +227,16 @@ class Global : public PersistentBase<T> {
226
227
227
228
template <typename S>
228
229
NAN_INLINE Global (const PersistentBase<S> &that)
229
- : PersistentBase<T>(that) {
230
+ : PersistentBase<T>(v8::Persistent<T>(v8::Isolate::GetCurrent(), that.persistent) ) {
230
231
TYPE_CHECK (T, S);
231
232
}
232
233
233
234
/* *
234
235
* Move constructor.
235
236
*/
236
237
NAN_INLINE Global (RValue rvalue)
237
- : PersistentBase<T>(rvalue.object. persistent) {
238
- rvalue.object ->Reset ();
238
+ : PersistentBase<T>(rvalue.object-> persistent) {
239
+ rvalue.object ->Empty ();
239
240
}
240
241
241
242
NAN_INLINE ~Global () { this ->Reset (); }
@@ -246,8 +247,8 @@ class Global : public PersistentBase<T> {
246
247
template <typename S>
247
248
NAN_INLINE Global &operator =(Global<S> rhs) {
248
249
TYPE_CHECK (T, S);
249
- this -> Reset ( rhs.persistent );
250
- rhs.Reset ();
250
+ std::memcpy (& rhs.persistent , & this -> persistent , sizeof (v8::Persistent<T>) );
251
+ rhs.Empty ();
251
252
return *this ;
252
253
}
253
254
0 commit comments