@@ -1679,16 +1679,30 @@ xmlNsPtr dom_get_nsdecl(xmlNode *node, xmlChar *localName) {
1679
1679
}
1680
1680
/* }}} end dom_get_nsdecl */
1681
1681
1682
+ static inline long dom_get_long (zval * offset ) /* {{{ */
1683
+ {
1684
+ if (Z_TYPE_P (offset ) == IS_LONG ) {
1685
+ return Z_LVAL_P (offset );
1686
+ } else {
1687
+ zval tmp ;
1688
+
1689
+ MAKE_COPY_ZVAL (& offset , & tmp );
1690
+ convert_to_long (& tmp );
1691
+
1692
+ return Z_LVAL (tmp );
1693
+ }
1694
+ }
1695
+ /* }}} */
1696
+
1682
1697
zval * dom_nodelist_read_dimension (zval * object , zval * offset , int type TSRMLS_DC ) /* {{{ */
1683
1698
{
1684
- zval * rv , offset_copy ;
1699
+ zval * rv , offset_copy = zval_used_for_init ;
1685
1700
1686
1701
if (!offset ) {
1687
1702
return NULL ;
1688
1703
}
1689
1704
1690
- MAKE_COPY_ZVAL (& offset , & offset_copy );
1691
- convert_to_long (& offset_copy );
1705
+ ZVAL_LONG (& offset_copy , dom_get_long (offset ));
1692
1706
1693
1707
zend_call_method_with_1_params (& object , Z_OBJCE_P (object ), NULL , "item" , & rv , & offset_copy );
1694
1708
@@ -1699,23 +1713,18 @@ zval *dom_nodelist_read_dimension(zval *object, zval *offset, int type TSRMLS_DC
1699
1713
1700
1714
int dom_nodelist_has_dimension (zval * object , zval * member , int check_empty TSRMLS_DC )
1701
1715
{
1702
- zval * length , offset_copy ;
1703
- int ret ;
1704
-
1705
- MAKE_COPY_ZVAL (& member , & offset_copy );
1706
- convert_to_long (& offset_copy );
1716
+ long offset = dom_get_long (member );
1707
1717
1708
- if (Z_LVAL ( offset_copy ) < 0 ) {
1718
+ if (offset < 0 ) {
1709
1719
return 0 ;
1710
- }
1711
-
1712
- length = zend_read_property (Z_OBJCE_P (object ), object , "length" , sizeof ("length" ) - 1 , 0 TSRMLS_CC );
1713
-
1714
- ret = Z_LVAL (offset_copy ) < Z_LVAL_P (length );
1720
+ } else {
1721
+ zval * length = zend_read_property (Z_OBJCE_P (object ), object , "length" , sizeof ("length" ) - 1 , 0 TSRMLS_CC );
1722
+ int ret = length && offset < Z_LVAL_P (length );
1715
1723
1716
- FREE_ZVAL (length );
1724
+ FREE_ZVAL (length );
1717
1725
1718
- return ret ;
1726
+ return ret ;
1727
+ }
1719
1728
} /* }}} end dom_nodelist_has_dimension */
1720
1729
1721
1730
#endif /* HAVE_DOM */
0 commit comments