@@ -203,8 +203,12 @@ Value::Value(const IniValue &value) : Value((const char *)value) {}
203
203
*/
204
204
Value::Value (const Value &that)
205
205
{
206
- // copy over the zval
207
- ZVAL_COPY (_val, that._val );
206
+ if (Z_ISREF_P (that._val )) {
207
+ zend_assign_to_variable (_val, that._val , IS_VAR);
208
+ }
209
+ else {
210
+ ZVAL_COPY (_val, that._val );
211
+ }
208
212
}
209
213
210
214
/* *
@@ -331,39 +335,7 @@ Value &Value::operator=(const Value &value)
331
335
// skip self assignment
332
336
if (this == &value) return *this ;
333
337
334
- // is the object a reference?
335
- if (Z_ISREF_P (_val))
336
- {
337
- // the current object is a reference, this means that we should
338
- // keep the zval object, and copy the other value into it, get
339
- // the current refcount
340
- int refcount = Z_REFCOUNT_P (_val);
341
-
342
- // clean up the current zval (but keep the zval structure)
343
- zval_dtor (_val);
344
-
345
- // make the copy
346
- *_val = *value._val ;
347
- zval_copy_ctor (_val);
348
-
349
- // restore refcount and reference setting
350
- ZVAL_MAKE_REF (_val);
351
- Z_SET_REFCOUNT_P (_val, refcount);
352
- }
353
- else
354
- {
355
- // destruct the zval (this function will decrement the reference counter,
356
- // and only destruct if there are no other references left)
357
- zval_ptr_dtor (_val);
358
-
359
- // just copy the zval, and the refcounter
360
- _val = value._val ;
361
-
362
- // and we have one more reference
363
- Z_TRY_ADDREF_P (_val);
364
- }
365
-
366
- // update the object
338
+ zend_assign_to_variable (_val, value._val , IS_VAR);
367
339
return *this ;
368
340
}
369
341
0 commit comments