61
61
} while (0)
62
62
63
63
#define CALCULATE_LITERAL_HASH (num ) do { \
64
- if (IS_INTERNED(Z_STRVAL(CONSTANT(num)))) { \
65
- Z_HASH_P(&CONSTANT(num)) = INTERNED_HASH(Z_STRVAL(CONSTANT(num))); \
66
- } else { \
67
- Z_HASH_P(&CONSTANT(num)) = zend_hash_func(Z_STRVAL(CONSTANT(num)), Z_STRLEN(CONSTANT(num))+1); \
68
- } \
64
+ zval *c = &CONSTANT(num); \
65
+ Z_HASH_P(c) = str_hash(Z_STRVAL_P(c), Z_STRLEN_P(c)); \
69
66
} while (0)
70
67
71
68
#define GET_CACHE_SLOT (literal ) do { \
@@ -107,9 +104,7 @@ ZEND_API zend_executor_globals executor_globals;
107
104
108
105
static void zend_duplicate_property_info (zend_property_info * property_info ) /* {{{ */
109
106
{
110
- if (!IS_INTERNED (property_info -> name )) {
111
- property_info -> name = estrndup (property_info -> name , property_info -> name_length );
112
- }
107
+ property_info -> name = str_estrndup (property_info -> name , property_info -> name_length );
113
108
if (property_info -> doc_comment ) {
114
109
property_info -> doc_comment = estrndup (property_info -> doc_comment , property_info -> doc_comment_len );
115
110
}
@@ -118,9 +113,7 @@ static void zend_duplicate_property_info(zend_property_info *property_info) /* {
118
113
119
114
static void zend_duplicate_property_info_internal (zend_property_info * property_info ) /* {{{ */
120
115
{
121
- if (!IS_INTERNED (property_info -> name )) {
122
- property_info -> name = zend_strndup (property_info -> name , property_info -> name_length );
123
- }
116
+ property_info -> name = str_strndup (property_info -> name , property_info -> name_length );
124
117
}
125
118
/* }}} */
126
119
@@ -657,13 +650,13 @@ void fetch_simple_variable_ex(znode *result, znode *varname, int bp, zend_uchar
657
650
zend_llist * fetch_list_ptr ;
658
651
659
652
if (varname -> op_type == IS_CONST ) {
660
- ulong hash = 0 ;
653
+ ulong hash ;
661
654
662
655
if (Z_TYPE (varname -> u .constant ) != IS_STRING ) {
663
656
convert_to_string (& varname -> u .constant );
664
- } else if (IS_INTERNED (Z_STRVAL (varname -> u .constant ))) {
665
- hash = INTERNED_HASH (Z_STRVAL (varname -> u .constant ));
666
657
}
658
+
659
+ hash = str_hash (Z_STRVAL (varname -> u .constant ), Z_STRLEN (varname -> u .constant ));
667
660
if (!zend_is_auto_global_quick (Z_STRVAL (varname -> u .constant ), Z_STRLEN (varname -> u .constant ), hash TSRMLS_CC ) &&
668
661
!(Z_STRLEN (varname -> u .constant ) == (sizeof ("this" )- 1 ) &&
669
662
!memcmp (Z_STRVAL (varname -> u .constant ), "this" , sizeof ("this" ))) &&
@@ -1568,16 +1561,11 @@ void zend_do_begin_function_declaration(znode *function_token, znode *function_n
1568
1561
op_array .line_start = zend_get_compiled_lineno (TSRMLS_C );
1569
1562
1570
1563
if (is_method ) {
1571
- int result ;
1564
+ zend_ulong hash ;
1572
1565
1573
1566
lcname = zend_new_interned_string (zend_str_tolower_dup (name , name_len ), name_len + 1 , 1 TSRMLS_CC );
1574
-
1575
- if (IS_INTERNED (lcname )) {
1576
- result = zend_hash_quick_add (& CG (active_class_entry )-> function_table , lcname , name_len + 1 , INTERNED_HASH (lcname ), & op_array , sizeof (zend_op_array ), (void * * ) & CG (active_op_array ));
1577
- } else {
1578
- result = zend_hash_add (& CG (active_class_entry )-> function_table , lcname , name_len + 1 , & op_array , sizeof (zend_op_array ), (void * * ) & CG (active_op_array ));
1579
- }
1580
- if (result == FAILURE ) {
1567
+ hash = str_hash (lcname , name_len );
1568
+ if (zend_hash_quick_add (& CG (active_class_entry )-> function_table , lcname , name_len + 1 , hash , & op_array , sizeof (zend_op_array ), (void * * ) & CG (active_op_array )) == FAILURE ) {
1581
1569
zend_error (E_COMPILE_ERROR , "Cannot redeclare %s::%s()" , CG (active_class_entry )-> name , name );
1582
1570
}
1583
1571
@@ -1840,7 +1828,7 @@ void zend_do_receive_arg(zend_uchar op, znode *varname, const znode *offset, con
1840
1828
zend_arg_info * cur_arg_info ;
1841
1829
znode var ;
1842
1830
1843
- if (zend_is_auto_global_quick (Z_STRVAL (varname -> u .constant ), Z_STRLEN (varname -> u .constant ), 0 TSRMLS_CC )) {
1831
+ if (zend_is_auto_global (Z_STRVAL (varname -> u .constant ), Z_STRLEN (varname -> u .constant ) TSRMLS_CC )) {
1844
1832
zend_error (E_COMPILE_ERROR , "Cannot re-assign auto-global variable %s" , Z_STRVAL (varname -> u .constant ));
1845
1833
} else {
1846
1834
var .op_type = IS_CV ;
@@ -1984,9 +1972,7 @@ void zend_do_begin_method_call(znode *left_bracket TSRMLS_DC) /* {{{ */
1984
1972
if (Z_TYPE (name ) != IS_STRING ) {
1985
1973
zend_error (E_COMPILE_ERROR , "Method name must be a string" );
1986
1974
}
1987
- if (!IS_INTERNED (Z_STRVAL (name ))) {
1988
- Z_STRVAL (name ) = estrndup (Z_STRVAL (name ), Z_STRLEN (name ));
1989
- }
1975
+ Z_STRVAL (name ) = str_estrndup (Z_STRVAL (name ), Z_STRLEN (name ));
1990
1976
FREE_POLYMORPHIC_CACHE_SLOT (last_op -> op2 .constant );
1991
1977
last_op -> op2 .constant =
1992
1978
zend_add_func_name_literal (CG (active_op_array ), & name TSRMLS_CC );
@@ -2112,7 +2098,7 @@ void zend_resolve_non_class_name(znode *element_name, zend_bool check_namespace
2112
2098
memcpy (Z_STRVAL (tmp .u .constant ), Z_STRVAL_P (CG (current_namespace )), Z_STRLEN_P (CG (current_namespace )));
2113
2099
memcpy (& (Z_STRVAL (tmp .u .constant )[Z_STRLEN_P (CG (current_namespace ))]), "\\" , sizeof ("\\" )- 1 );
2114
2100
memcpy (& (Z_STRVAL (tmp .u .constant )[Z_STRLEN_P (CG (current_namespace )) + sizeof ("\\" )- 1 ]), Z_STRVAL (element_name -> u .constant ), Z_STRLEN (element_name -> u .constant )+ 1 );
2115
- STR_FREE (Z_STRVAL (element_name -> u .constant ));
2101
+ str_efree (Z_STRVAL (element_name -> u .constant ));
2116
2102
* element_name = tmp ;
2117
2103
}
2118
2104
}
@@ -2405,14 +2391,14 @@ void zend_do_build_full_name(znode *result, znode *prefix, znode *name, int is_c
2405
2391
Z_STRVAL (result -> u .constant ) = erealloc (Z_STRVAL (result -> u .constant ), length + 1 );
2406
2392
memcpy (& Z_STRVAL (result -> u .constant )[Z_STRLEN (result -> u .constant )], "::" , sizeof ("::" )- 1 );
2407
2393
memcpy (& Z_STRVAL (result -> u .constant )[Z_STRLEN (result -> u .constant ) + sizeof ("::" )- 1 ], Z_STRVAL (name -> u .constant ), Z_STRLEN (name -> u .constant )+ 1 );
2408
- STR_FREE (Z_STRVAL (name -> u .constant ));
2394
+ str_efree (Z_STRVAL (name -> u .constant ));
2409
2395
Z_STRLEN (result -> u .constant ) = length ;
2410
2396
} else {
2411
2397
length = sizeof ("\\" )- 1 + Z_STRLEN (result -> u .constant ) + Z_STRLEN (name -> u .constant );
2412
2398
Z_STRVAL (result -> u .constant ) = erealloc (Z_STRVAL (result -> u .constant ), length + 1 );
2413
2399
memcpy (& Z_STRVAL (result -> u .constant )[Z_STRLEN (result -> u .constant )], "\\" , sizeof ("\\" )- 1 );
2414
2400
memcpy (& Z_STRVAL (result -> u .constant )[Z_STRLEN (result -> u .constant ) + sizeof ("\\" )- 1 ], Z_STRVAL (name -> u .constant ), Z_STRLEN (name -> u .constant )+ 1 );
2415
- STR_FREE (Z_STRVAL (name -> u .constant ));
2401
+ str_efree (Z_STRVAL (name -> u .constant ));
2416
2402
Z_STRLEN (result -> u .constant ) = length ;
2417
2403
}
2418
2404
}
@@ -5305,7 +5291,7 @@ void zend_do_declare_class_constant(znode *var_name, const znode *value TSRMLS_D
5305
5291
{
5306
5292
zval * property ;
5307
5293
const char * cname = NULL ;
5308
- int result ;
5294
+ zend_ulong hash ;
5309
5295
5310
5296
if (Z_TYPE (value -> u .constant ) == IS_CONSTANT_ARRAY ) {
5311
5297
zend_error (E_COMPILE_ERROR , "Arrays are not allowed in class constants" );
@@ -5320,13 +5306,8 @@ void zend_do_declare_class_constant(znode *var_name, const znode *value TSRMLS_D
5320
5306
* property = value -> u .constant ;
5321
5307
5322
5308
cname = zend_new_interned_string (Z_STRVAL (var_name -> u .constant ), Z_STRLEN (var_name -> u .constant )+ 1 , 0 TSRMLS_CC );
5323
-
5324
- if (IS_INTERNED (cname )) {
5325
- result = zend_hash_quick_add (& CG (active_class_entry )-> constants_table , cname , Z_STRLEN (var_name -> u .constant )+ 1 , INTERNED_HASH (cname ), & property , sizeof (zval * ), NULL );
5326
- } else {
5327
- result = zend_hash_add (& CG (active_class_entry )-> constants_table , cname , Z_STRLEN (var_name -> u .constant )+ 1 , & property , sizeof (zval * ), NULL );
5328
- }
5329
- if (result == FAILURE ) {
5309
+ hash = str_hash (cname , Z_STRLEN (var_name -> u .constant ));
5310
+ if (zend_hash_quick_add (& CG (active_class_entry )-> constants_table , cname , Z_STRLEN (var_name -> u .constant )+ 1 , hash , & property , sizeof (zval * ), NULL ) == FAILURE ) {
5330
5311
FREE_ZVAL (property );
5331
5312
zend_error (E_COMPILE_ERROR , "Cannot redefine class constant %s::%s" , CG (active_class_entry )-> name , Z_STRVAL (var_name -> u .constant ));
5332
5313
}
@@ -6692,10 +6673,9 @@ void zend_do_ticks(TSRMLS_D) /* {{{ */
6692
6673
}
6693
6674
/* }}} */
6694
6675
6695
- zend_bool zend_is_auto_global_quick (const char * name , uint name_len , ulong hashval TSRMLS_DC ) /* {{{ */
6676
+ zend_bool zend_is_auto_global_quick (const char * name , uint name_len , ulong hash TSRMLS_DC ) /* {{{ */
6696
6677
{
6697
6678
zend_auto_global * auto_global ;
6698
- ulong hash = hashval ? hashval : zend_hash_func (name , name_len + 1 );
6699
6679
6700
6680
if (zend_hash_quick_find (CG (auto_globals ), name , name_len + 1 , hash , (void * * ) & auto_global )== SUCCESS ) {
6701
6681
if (auto_global -> armed ) {
@@ -6709,7 +6689,7 @@ zend_bool zend_is_auto_global_quick(const char *name, uint name_len, ulong hashv
6709
6689
6710
6690
zend_bool zend_is_auto_global (const char * name , uint name_len TSRMLS_DC ) /* {{{ */
6711
6691
{
6712
- return zend_is_auto_global_quick (name , name_len , 0 TSRMLS_CC );
6692
+ return zend_is_auto_global_quick (name , name_len , zend_hash_func ( name , name_len + 1 ) TSRMLS_CC );
6713
6693
}
6714
6694
/* }}} */
6715
6695
0 commit comments