Skip to content

Commit 1eb4352

Browse files
committed
Use new ZEND_HASH_FOREACH_... API.
1 parent 4a875e1 commit 1eb4352

File tree

13 files changed

+84
-198
lines changed

13 files changed

+84
-198
lines changed

ext/dom/php_dom.c

+4-13
Original file line numberDiff line numberDiff line change
@@ -418,7 +418,7 @@ static HashTable* dom_get_debug_info_helper(zval *object, int *is_temp) /* {{{ *
418418
HashTable *debug_info,
419419
*prop_handlers = obj->prop_handler,
420420
*std_props;
421-
HashPosition pos;
421+
zend_string *string_key;
422422
dom_prop_handler *entry;
423423
zval object_value;
424424

@@ -435,19 +435,10 @@ static HashTable* dom_get_debug_info_helper(zval *object, int *is_temp) /* {{{ *
435435

436436
ZVAL_STRING(&object_value, "(object value omitted)");
437437

438-
for (zend_hash_internal_pointer_reset_ex(prop_handlers, &pos);
439-
(entry = zend_hash_get_current_data_ptr_ex(prop_handlers, &pos)) != NULL;
440-
zend_hash_move_forward_ex(prop_handlers, &pos)) {
438+
ZEND_HASH_FOREACH_STR_KEY_PTR(prop_handlers, string_key, entry) {
441439
zval value;
442-
zend_string *string_key;
443-
zend_ulong num_key;
444440

445-
if (entry->read_func(obj, &value) == FAILURE) {
446-
continue;
447-
}
448-
449-
if (zend_hash_get_current_key_ex(prop_handlers, &string_key,
450-
&num_key, &pos) != HASH_KEY_IS_STRING) {
441+
if (entry->read_func(obj, &value) == FAILURE || !string_key) {
451442
continue;
452443
}
453444

@@ -457,7 +448,7 @@ static HashTable* dom_get_debug_info_helper(zval *object, int *is_temp) /* {{{ *
457448
}
458449

459450
zend_hash_add(debug_info, string_key, &value);
460-
}
451+
} ZEND_HASH_FOREACH_END();
461452

462453
zval_dtor(&object_value);
463454

ext/dom/xpath.c

+2-4
Original file line numberDiff line numberDiff line change
@@ -520,14 +520,12 @@ PHP_FUNCTION(dom_xpath_register_php_functions)
520520

521521
if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS(), "a", &array_value) == SUCCESS) {
522522
intern = Z_XPATHOBJ_P(id);
523-
zend_hash_internal_pointer_reset(Z_ARRVAL_P(array_value));
524-
while ((entry = zend_hash_get_current_data(Z_ARRVAL_P(array_value)))) {
523+
ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(array_value), entry) {
525524
zend_string *str = zval_get_string(entry);
526525
ZVAL_LONG(&new_string,1);
527526
zend_hash_update(intern->registered_phpfunctions, str, &new_string);
528-
zend_hash_move_forward(Z_ARRVAL_P(array_value));
529527
zend_string_release(str);
530-
}
528+
} ZEND_HASH_FOREACH_END();
531529
intern->registerPhpFunctions = 2;
532530
RETURN_TRUE;
533531

ext/mysqlnd/mysqlnd_plugin.c

-4
Original file line numberDiff line numberDiff line change
@@ -168,10 +168,6 @@ PHPAPI void * _mysqlnd_plugin_find(const char * const name)
168168
/* {{{ _mysqlnd_plugin_apply_with_argument */
169169
PHPAPI void _mysqlnd_plugin_apply_with_argument(apply_func_arg_t apply_func, void * argument)
170170
{
171-
/* Note: We want to be thread-safe (read-only), so we can use neither
172-
* zend_hash_apply_with_argument nor zend_hash_internal_pointer_reset and
173-
* friends
174-
*/
175171
zval *val;
176172
int result;
177173

ext/pdo/pdo_sql_parser.c

+14-18
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* Generated by re2c 0.13.7.5 */
1+
/* Generated by re2c 0.13.5 */
22
#line 1 "ext/pdo/pdo_sql_parser.re"
33
/*
44
+----------------------------------------------------------------------+
@@ -70,10 +70,9 @@ static int scan(Scanner *s)
7070
}
7171
yy2:
7272
YYCURSOR = YYMARKER;
73-
if (yyaccept == 0) {
74-
goto yy4;
75-
} else {
76-
goto yy10;
73+
switch (yyaccept) {
74+
case 0: goto yy4;
75+
case 1: goto yy10;
7776
}
7877
yy3:
7978
yyaccept = 0;
@@ -82,7 +81,7 @@ static int scan(Scanner *s)
8281
yy4:
8382
#line 63 "ext/pdo/pdo_sql_parser.re"
8483
{ SKIP_ONE(PDO_PARSER_TEXT); }
85-
#line 86 "ext/pdo/pdo_sql_parser.c"
84+
#line 85 "ext/pdo/pdo_sql_parser.c"
8685
yy5:
8786
yyaccept = 0;
8887
yych = *(YYMARKER = ++YYCURSOR);
@@ -166,7 +165,7 @@ static int scan(Scanner *s)
166165
yy8:
167166
#line 62 "ext/pdo/pdo_sql_parser.re"
168167
{ RET(PDO_PARSER_BIND_POS); }
169-
#line 170 "ext/pdo/pdo_sql_parser.c"
168+
#line 169 "ext/pdo/pdo_sql_parser.c"
170169
yy9:
171170
++YYCURSOR;
172171
switch ((yych = *YYCURSOR)) {
@@ -176,7 +175,7 @@ static int scan(Scanner *s)
176175
yy10:
177176
#line 65 "ext/pdo/pdo_sql_parser.re"
178177
{ RET(PDO_PARSER_TEXT); }
179-
#line 180 "ext/pdo/pdo_sql_parser.c"
178+
#line 179 "ext/pdo/pdo_sql_parser.c"
180179
yy11:
181180
yych = *++YYCURSOR;
182181
switch (yych) {
@@ -213,7 +212,7 @@ static int scan(Scanner *s)
213212
yy16:
214213
#line 64 "ext/pdo/pdo_sql_parser.re"
215214
{ RET(PDO_PARSER_TEXT); }
216-
#line 217 "ext/pdo/pdo_sql_parser.c"
215+
#line 216 "ext/pdo/pdo_sql_parser.c"
217216
yy17:
218217
++YYCURSOR;
219218
if (YYLIMIT <= YYCURSOR) YYFILL(1);
@@ -293,7 +292,7 @@ static int scan(Scanner *s)
293292
yy31:
294293
#line 60 "ext/pdo/pdo_sql_parser.re"
295294
{ RET(PDO_PARSER_TEXT); }
296-
#line 297 "ext/pdo/pdo_sql_parser.c"
295+
#line 296 "ext/pdo/pdo_sql_parser.c"
297296
yy32:
298297
++YYCURSOR;
299298
if (YYLIMIT <= YYCURSOR) YYFILL(1);
@@ -367,7 +366,7 @@ static int scan(Scanner *s)
367366
yy34:
368367
#line 61 "ext/pdo/pdo_sql_parser.re"
369368
{ RET(PDO_PARSER_BIND); }
370-
#line 371 "ext/pdo/pdo_sql_parser.c"
369+
#line 370 "ext/pdo/pdo_sql_parser.c"
371370
yy35:
372371
++YYCURSOR;
373372
if (YYLIMIT <= YYCURSOR) YYFILL(1);
@@ -397,7 +396,7 @@ static int scan(Scanner *s)
397396
++YYCURSOR;
398397
#line 59 "ext/pdo/pdo_sql_parser.re"
399398
{ RET(PDO_PARSER_TEXT); }
400-
#line 401 "ext/pdo/pdo_sql_parser.c"
399+
#line 400 "ext/pdo/pdo_sql_parser.c"
401400
yy42:
402401
++YYCURSOR;
403402
if (YYLIMIT <= YYCURSOR) YYFILL(1);
@@ -419,7 +418,7 @@ static int scan(Scanner *s)
419418
++YYCURSOR;
420419
#line 58 "ext/pdo/pdo_sql_parser.re"
421420
{ RET(PDO_PARSER_TEXT); }
422-
#line 423 "ext/pdo/pdo_sql_parser.c"
421+
#line 422 "ext/pdo/pdo_sql_parser.c"
423422
}
424423
#line 66 "ext/pdo/pdo_sql_parser.re"
425424

@@ -781,9 +780,7 @@ int old_pdo_parse_params(pdo_stmt_t *stmt, char *inquery, int inquery_len, char
781780
padding = 3;
782781
}
783782
if(params) {
784-
HashPosition *param_pos;
785-
zend_hash_internal_pointer_reset(params);
786-
while ((param == zend_hash_get_current_data_ptr_ex(params, &param_pos)) != NULL) {
783+
ZEND_HASH_FOREACH_PTR(params, param) {
787784
if(param->parameter) {
788785
convert_to_string(param->parameter);
789786
/* accommodate a string that needs to be fully quoted
@@ -792,8 +789,7 @@ int old_pdo_parse_params(pdo_stmt_t *stmt, char *inquery, int inquery_len, char
792789
*/
793790
newbuffer_len += padding * Z_STRLEN_P(param->parameter);
794791
}
795-
zend_hash_move_forward(params);
796-
}
792+
} ZEND_HASH_FOREACH_END();
797793
}
798794
*outquery = (char *) emalloc(newbuffer_len + 1);
799795
*outquery_len = 0;

ext/pdo/pdo_sql_parser.re

+2-5
Original file line numberDiff line numberDiff line change
@@ -422,9 +422,7 @@ int old_pdo_parse_params(pdo_stmt_t *stmt, char *inquery, int inquery_len, char
422422
padding = 3;
423423
}
424424
if(params) {
425-
HashPosition *param_pos;
426-
zend_hash_internal_pointer_reset(params);
427-
while ((param == zend_hash_get_current_data_ptr_ex(params, &param_pos)) != NULL) {
425+
ZEND_HASH_FOREACH_PTR(params, param) {
428426
if(param->parameter) {
429427
convert_to_string(param->parameter);
430428
/* accommodate a string that needs to be fully quoted
@@ -433,8 +431,7 @@ int old_pdo_parse_params(pdo_stmt_t *stmt, char *inquery, int inquery_len, char
433431
*/
434432
newbuffer_len += padding * Z_STRLEN_P(param->parameter);
435433
}
436-
zend_hash_move_forward(params);
437-
}
434+
} ZEND_HASH_FOREACH_END();
438435
}
439436
*outquery = (char *) emalloc(newbuffer_len + 1);
440437
*outquery_len = 0;

0 commit comments

Comments
 (0)