@@ -374,9 +374,8 @@ ZEND_API void ZEND_FASTCALL convert_to_long_base(zval *op, int base) /* {{{ */
374
374
zval_dtor (op );
375
375
376
376
if (Z_TYPE (dst ) == IS_LONG ) {
377
- ZVAL_COPY_VALUE (op , & dst );
377
+ ZVAL_LONG (op , Z_LVAL ( dst ) );
378
378
} else {
379
-
380
379
ZVAL_LONG (op , 1 );
381
380
}
382
381
return ;
@@ -434,7 +433,7 @@ ZEND_API void ZEND_FASTCALL convert_to_double(zval *op) /* {{{ */
434
433
zval_dtor (op );
435
434
436
435
if (Z_TYPE (dst ) == IS_DOUBLE ) {
437
- ZVAL_COPY_VALUE (op , & dst );
436
+ ZVAL_DOUBLE (op , Z_DVAL ( dst ) );
438
437
} else {
439
438
ZVAL_DOUBLE (op , 1.0 );
440
439
}
@@ -505,8 +504,8 @@ ZEND_API void ZEND_FASTCALL convert_to_boolean(zval *op) /* {{{ */
505
504
convert_object_to_type (op , & dst , _IS_BOOL , convert_to_boolean );
506
505
zval_dtor (op );
507
506
508
- if (Z_TYPE (dst ) == IS_FALSE || Z_TYPE (dst ) == IS_TRUE ) {
509
- ZVAL_COPY_VALUE (op , & dst );
507
+ if (Z_TYPE_INFO (dst ) == IS_FALSE || Z_TYPE_INFO (dst ) == IS_TRUE ) {
508
+ Z_TYPE_INFO_P (op ) = Z_TYPE_INFO ( dst );
510
509
} else {
511
510
ZVAL_TRUE (op );
512
511
}
@@ -596,12 +595,9 @@ ZEND_API void ZEND_FASTCALL _convert_to_string(zval *op ZEND_FILE_LINE_DC) /* {{
596
595
597
596
static void convert_scalar_to_array (zval * op ) /* {{{ */
598
597
{
599
- zval entry ;
600
-
601
- ZVAL_COPY_VALUE (& entry , op );
602
-
603
- array_init_size (op , 1 );
604
- zend_hash_index_add_new (Z_ARRVAL_P (op ), 0 , & entry );
598
+ HashTable * ht = zend_new_array (1 );
599
+ zend_hash_index_add_new (ht , 0 , op );
600
+ ZVAL_ARR (op , ht );
605
601
}
606
602
/* }}} */
607
603
@@ -619,19 +615,13 @@ ZEND_API void ZEND_FASTCALL convert_to_array(zval *op) /* {{{ */
619
615
if (Z_OBJ_HT_P (op )-> get_properties ) {
620
616
HashTable * obj_ht = Z_OBJ_HT_P (op )-> get_properties (op );
621
617
if (obj_ht ) {
622
- zend_array * arr ;
623
-
624
618
/* fast copy */
625
- if (!Z_OBJCE_P (op )-> default_properties_count &&
626
- obj_ht == Z_OBJ_P (op )-> properties &&
627
- !GC_IS_RECURSIVE (obj_ht ) &&
628
- EXPECTED (Z_OBJ_P (op )-> handlers == & std_object_handlers )) {
629
- arr = zend_proptable_to_symtable (obj_ht , 0 );
630
- } else {
631
- arr = zend_proptable_to_symtable (obj_ht , 1 );
632
- }
619
+ obj_ht = zend_proptable_to_symtable (obj_ht ,
620
+ (Z_OBJCE_P (op )-> default_properties_count ||
621
+ Z_OBJ_P (op )-> handlers != & std_object_handlers ||
622
+ GC_IS_RECURSIVE (obj_ht )));
633
623
zval_dtor (op );
634
- ZVAL_ARR (op , arr );
624
+ ZVAL_ARR (op , obj_ht );
635
625
return ;
636
626
}
637
627
} else {
@@ -670,14 +660,20 @@ ZEND_API void ZEND_FASTCALL convert_to_object(zval *op) /* {{{ */
670
660
switch (Z_TYPE_P (op )) {
671
661
case IS_ARRAY :
672
662
{
673
- HashTable * ht = Z_ARR_P (op );
674
- ht = zend_symtable_to_proptable (ht );
663
+ HashTable * ht = zend_symtable_to_proptable (Z_ARR_P (op ));
664
+ zend_object * obj ;
665
+
675
666
if (GC_FLAGS (ht ) & IS_ARRAY_IMMUTABLE ) {
676
667
/* TODO: try not to duplicate immutable arrays as well ??? */
677
668
ht = zend_array_dup (ht );
669
+ } else if (ht != Z_ARR_P (op )) {
670
+ zval_dtor (op );
671
+ } else {
672
+ GC_DELREF (ht );
678
673
}
679
- zval_dtor (op );
680
- object_and_properties_init (op , zend_standard_class_def , ht );
674
+ obj = zend_objects_new (zend_standard_class_def );
675
+ obj -> properties = ht ;
676
+ ZVAL_OBJ (op , obj );
681
677
break ;
682
678
}
683
679
case IS_OBJECT :
0 commit comments