@@ -84,8 +84,9 @@ template<typename T> class PersistentBase {
8484 private:
8585 NAN_INLINE PersistentBase () :
8686 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+ }
8990 NAN_INLINE explicit PersistentBase (v8::Local<T> that) :
9091 persistent(v8::Isolate::GetCurrent(), that) { }
9192 template <typename S, typename M> friend class Persistent ;
@@ -181,12 +182,12 @@ class Global : public PersistentBase<T> {
181182
182183 template <class S >
183184 NAN_INLINE Global (const PersistentBase<S>& that)
184- : PersistentBase<T>(that) {
185+ : PersistentBase<T>(v8::Persistent<T>(v8::Isolate::GetCurrent(), that.persistent) ) {
185186 TYPE_CHECK (T, S);
186187 }
187188
188189 NAN_INLINE Global (Global&& other) : PersistentBase<T>(other.persistent) {
189- other.Reset ();
190+ other.Empty ();
190191 }
191192
192193 NAN_INLINE ~Global () { this ->Reset (); }
@@ -195,8 +196,8 @@ class Global : public PersistentBase<T> {
195196 NAN_INLINE Global& operator =(Global<S>&& rhs) {
196197 TYPE_CHECK (T, S);
197198 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 ();
200201 }
201202 return *this ;
202203 }
@@ -226,16 +227,16 @@ class Global : public PersistentBase<T> {
226227
227228 template <typename S>
228229 NAN_INLINE Global (const PersistentBase<S> &that)
229- : PersistentBase<T>(that) {
230+ : PersistentBase<T>(v8::Persistent<T>(v8::Isolate::GetCurrent(), that.persistent) ) {
230231 TYPE_CHECK (T, S);
231232 }
232233
233234 /* *
234235 * Move constructor.
235236 */
236237 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 ();
239240 }
240241
241242 NAN_INLINE ~Global () { this ->Reset (); }
@@ -246,8 +247,8 @@ class Global : public PersistentBase<T> {
246247 template <typename S>
247248 NAN_INLINE Global &operator =(Global<S> rhs) {
248249 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 ();
251252 return *this ;
252253 }
253254
0 commit comments