@@ -1529,91 +1529,155 @@ PHP_FUNCTION(array_walk_recursive)
15291529 */
15301530static inline void _php_search_array (zval * return_value , zval * value , zval * array , bool strict , int behavior ) /* {{{ */
15311531{
1532- zval * entry ; /* pointer to array entry */
1532+ zval * entry ;
15331533 zend_ulong num_idx ;
15341534 zend_string * str_idx ;
15351535
15361536 if (strict ) {
15371537 if (Z_TYPE_P (value ) == IS_LONG ) {
1538- ZEND_HASH_FOREACH_KEY_VAL (Z_ARRVAL_P (array ), num_idx , str_idx , entry ) {
1539- ZVAL_DEREF (entry );
1540- if (Z_TYPE_P (entry ) == IS_LONG && Z_LVAL_P (entry ) == Z_LVAL_P (value )) {
1541- if (behavior == 0 ) {
1542- RETURN_TRUE ;
1543- } else {
1538+ if (behavior == 0 ) {
1539+ if (HT_IS_PACKED (Z_ARRVAL_P (array ))) {
1540+ ZEND_HASH_PACKED_FOREACH_VAL (Z_ARRVAL_P (array ), entry ) {
1541+ ZVAL_DEREF (entry );
1542+ if (Z_TYPE_P (entry ) == IS_LONG && Z_LVAL_P (entry ) == Z_LVAL_P (value )) {
1543+ RETURN_TRUE ;
1544+ }
1545+ } ZEND_HASH_FOREACH_END ();
1546+ } else {
1547+ ZEND_HASH_FOREACH_KEY_VAL (Z_ARRVAL_P (array ), num_idx , str_idx , entry )
1548+ {
1549+ ZVAL_DEREF (entry );
1550+ if (Z_TYPE_P (entry ) == IS_LONG && Z_LVAL_P (entry ) == Z_LVAL_P (value )) {
1551+ RETURN_TRUE ;
1552+ }
1553+ } ZEND_HASH_FOREACH_END ();
1554+ }
1555+ } else {
1556+ ZEND_HASH_FOREACH_KEY_VAL (Z_ARRVAL_P (array ), num_idx , str_idx , entry ) {
1557+ ZVAL_DEREF (entry );
1558+ if (Z_TYPE_P (entry ) == IS_LONG && Z_LVAL_P (entry ) == Z_LVAL_P (value )) {
15441559 if (str_idx ) {
15451560 RETURN_STR_COPY (str_idx );
15461561 } else {
15471562 RETURN_LONG (num_idx );
15481563 }
15491564 }
1550- }
1551- } ZEND_HASH_FOREACH_END ();
1565+ } ZEND_HASH_FOREACH_END ();
1566+ }
15521567 } else {
1553- ZEND_HASH_FOREACH_KEY_VAL (Z_ARRVAL_P (array ), num_idx , str_idx , entry ) {
1554- ZVAL_DEREF (entry );
1555- if (fast_is_identical_function (value , entry )) {
1556- if (behavior == 0 ) {
1557- RETURN_TRUE ;
1558- } else {
1568+ if (behavior == 0 ) {
1569+ if (HT_IS_PACKED (Z_ARRVAL_P (array ))) {
1570+ ZEND_HASH_PACKED_FOREACH_VAL (Z_ARRVAL_P (array ), entry ) {
1571+ ZVAL_DEREF (entry );
1572+ if (fast_is_identical_function (value , entry )) {
1573+ RETURN_TRUE ;
1574+ }
1575+ } ZEND_HASH_FOREACH_END ();
1576+ } else {
1577+ ZEND_HASH_FOREACH_KEY_VAL (Z_ARRVAL_P (array ), num_idx , str_idx , entry ) {
1578+ ZVAL_DEREF (entry );
1579+ if (fast_is_identical_function (value , entry )) {
1580+ RETURN_TRUE ;
1581+ }
1582+ } ZEND_HASH_FOREACH_END ();
1583+ }
1584+ } else {
1585+ ZEND_HASH_FOREACH_KEY_VAL (Z_ARRVAL_P (array ), num_idx , str_idx , entry ) {
1586+ ZVAL_DEREF (entry );
1587+ if (fast_is_identical_function (value , entry )) {
15591588 if (str_idx ) {
15601589 RETURN_STR_COPY (str_idx );
15611590 } else {
15621591 RETURN_LONG (num_idx );
15631592 }
15641593 }
1565- }
1566- } ZEND_HASH_FOREACH_END ();
1594+ } ZEND_HASH_FOREACH_END ();
1595+ }
15671596 }
15681597 } else {
15691598 if (Z_TYPE_P (value ) == IS_LONG ) {
1570- ZEND_HASH_FOREACH_KEY_VAL (Z_ARRVAL_P (array ), num_idx , str_idx , entry ) {
1571- if (fast_equal_check_long (value , entry )) {
1572- if (behavior == 0 ) {
1573- RETURN_TRUE ;
1574- } else {
1599+ if (behavior == 0 ) {
1600+ if (HT_IS_PACKED (Z_ARRVAL_P (array ))) {
1601+ ZEND_HASH_PACKED_FOREACH_VAL (Z_ARRVAL_P (array ), entry ) {
1602+ if (fast_equal_check_long (value , entry )) {
1603+ RETURN_TRUE ;
1604+ }
1605+ } ZEND_HASH_FOREACH_END ();
1606+ } else {
1607+ ZEND_HASH_FOREACH_KEY_VAL (Z_ARRVAL_P (array ), num_idx , str_idx , entry ) {
1608+ if (fast_equal_check_long (value , entry )) {
1609+ RETURN_TRUE ;
1610+ }
1611+ } ZEND_HASH_FOREACH_END ();
1612+ }
1613+ } else {
1614+ ZEND_HASH_FOREACH_KEY_VAL (Z_ARRVAL_P (array ), num_idx , str_idx , entry ) {
1615+ if (fast_equal_check_long (value , entry )) {
15751616 if (str_idx ) {
15761617 RETURN_STR_COPY (str_idx );
15771618 } else {
15781619 RETURN_LONG (num_idx );
15791620 }
15801621 }
1581- }
1582- } ZEND_HASH_FOREACH_END ();
1622+ } ZEND_HASH_FOREACH_END ();
1623+ }
15831624 } else if (Z_TYPE_P (value ) == IS_STRING ) {
1584- ZEND_HASH_FOREACH_KEY_VAL (Z_ARRVAL_P (array ), num_idx , str_idx , entry ) {
1585- if (fast_equal_check_string (value , entry )) {
1586- if (behavior == 0 ) {
1587- RETURN_TRUE ;
1588- } else {
1625+ if (behavior == 0 ) {
1626+ if (HT_IS_PACKED (Z_ARRVAL_P (array ))) {
1627+ ZEND_HASH_PACKED_FOREACH_VAL (Z_ARRVAL_P (array ), entry ) {
1628+ if (fast_equal_check_string (value , entry )) {
1629+ RETURN_TRUE ;
1630+ }
1631+ } ZEND_HASH_FOREACH_END ();
1632+ } else {
1633+ ZEND_HASH_FOREACH_KEY_VAL (Z_ARRVAL_P (array ), num_idx , str_idx , entry ) {
1634+ if (fast_equal_check_string (value , entry )) {
1635+ RETURN_TRUE ;
1636+ }
1637+ } ZEND_HASH_FOREACH_END ();
1638+ }
1639+ } else {
1640+ ZEND_HASH_FOREACH_KEY_VAL (Z_ARRVAL_P (array ), num_idx , str_idx , entry ) {
1641+ if (fast_equal_check_string (value , entry )) {
15891642 if (str_idx ) {
15901643 RETURN_STR_COPY (str_idx );
15911644 } else {
15921645 RETURN_LONG (num_idx );
15931646 }
15941647 }
1595- }
1596- } ZEND_HASH_FOREACH_END ();
1648+ } ZEND_HASH_FOREACH_END ();
1649+ }
15971650 } else {
1598- ZEND_HASH_FOREACH_KEY_VAL (Z_ARRVAL_P (array ), num_idx , str_idx , entry ) {
1599- if (fast_equal_check_function (value , entry )) {
1600- if (behavior == 0 ) {
1601- RETURN_TRUE ;
1602- } else {
1651+ if (behavior == 0 ) {
1652+ if (HT_IS_PACKED (Z_ARRVAL_P (array ))) {
1653+ ZEND_HASH_PACKED_FOREACH_VAL (Z_ARRVAL_P (array ), entry ) {
1654+ if (fast_equal_check_function (value , entry )) {
1655+ RETURN_TRUE ;
1656+ }
1657+ } ZEND_HASH_FOREACH_END ();
1658+ } else {
1659+ ZEND_HASH_FOREACH_KEY_VAL (Z_ARRVAL_P (array ), num_idx , str_idx , entry ) {
1660+ if (fast_equal_check_function (value , entry )) {
1661+ RETURN_TRUE ;
1662+ }
1663+ } ZEND_HASH_FOREACH_END ();
1664+ }
1665+ } else {
1666+ ZEND_HASH_FOREACH_KEY_VAL (Z_ARRVAL_P (array ), num_idx , str_idx , entry ) {
1667+ if (fast_equal_check_function (value , entry )) {
16031668 if (str_idx ) {
16041669 RETURN_STR_COPY (str_idx );
16051670 } else {
16061671 RETURN_LONG (num_idx );
16071672 }
16081673 }
1609- }
1610- } ZEND_HASH_FOREACH_END ();
1674+ } ZEND_HASH_FOREACH_END ();
1675+ }
16111676 }
16121677 }
16131678
16141679 RETURN_FALSE ;
16151680}
1616- /* }}} */
16171681
16181682/* void php_search_array(INTERNAL_FUNCTION_PARAMETERS, int behavior)
16191683 * 0 = return boolean
0 commit comments