Skip to content

Commit 4fca8a6

Browse files
authored
ext/intl: SpoofChecker using fast ZPP. (#14412)
1 parent dedf8fb commit 4fca8a6

File tree

2 files changed

+21
-19
lines changed

2 files changed

+21
-19
lines changed

ext/intl/spoofchecker/spoofchecker_create.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,7 @@ PHP_METHOD(Spoofchecker, __construct)
2929
zend_error_handling error_handling;
3030
SPOOFCHECKER_METHOD_INIT_VARS;
3131

32-
if (zend_parse_parameters_none() == FAILURE) {
33-
RETURN_THROWS();
34-
}
32+
ZEND_PARSE_PARAMETERS_NONE();
3533

3634
zend_replace_error_handling(EH_THROW, IntlException_ce_ptr, &error_handling);
3735

ext/intl/spoofchecker/spoofchecker_main.c

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,11 @@ PHP_METHOD(Spoofchecker, isSuspicious)
2828
zval *error_code = NULL;
2929
SPOOFCHECKER_METHOD_INIT_VARS;
3030

31-
if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS(), "s|z", &text, &text_len, &error_code)) {
32-
RETURN_THROWS();
33-
}
31+
ZEND_PARSE_PARAMETERS_START(1, 2)
32+
Z_PARAM_STRING(text, text_len)
33+
Z_PARAM_OPTIONAL
34+
Z_PARAM_ZVAL_OR_NULL(error_code)
35+
ZEND_PARSE_PARAMETERS_END();
3436

3537
SPOOFCHECKER_METHOD_FETCH_OBJECT;
3638

@@ -70,10 +72,12 @@ PHP_METHOD(Spoofchecker, areConfusable)
7072
zval *error_code = NULL;
7173
SPOOFCHECKER_METHOD_INIT_VARS;
7274

73-
if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS(), "ss|z", &s1, &s1_len,
74-
&s2, &s2_len, &error_code)) {
75-
RETURN_THROWS();
76-
}
75+
ZEND_PARSE_PARAMETERS_START(2, 3)
76+
Z_PARAM_STRING(s1, s1_len)
77+
Z_PARAM_STRING(s2, s2_len)
78+
Z_PARAM_OPTIONAL
79+
Z_PARAM_ZVAL_OR_NULL(error_code)
80+
ZEND_PARSE_PARAMETERS_END();
7781

7882
SPOOFCHECKER_METHOD_FETCH_OBJECT;
7983
if(s1_len > INT32_MAX || s2_len > INT32_MAX) {
@@ -102,9 +106,9 @@ PHP_METHOD(Spoofchecker, setAllowedLocales)
102106
size_t locales_len;
103107
SPOOFCHECKER_METHOD_INIT_VARS;
104108

105-
if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS(), "s", &locales, &locales_len)) {
106-
RETURN_THROWS();
107-
}
109+
ZEND_PARSE_PARAMETERS_START(1, 1)
110+
Z_PARAM_STRING(locales, locales_len)
111+
ZEND_PARSE_PARAMETERS_END();
108112

109113
SPOOFCHECKER_METHOD_FETCH_OBJECT;
110114

@@ -123,9 +127,9 @@ PHP_METHOD(Spoofchecker, setChecks)
123127
zend_long checks;
124128
SPOOFCHECKER_METHOD_INIT_VARS;
125129

126-
if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS(), "l", &checks)) {
127-
RETURN_THROWS();
128-
}
130+
ZEND_PARSE_PARAMETERS_START(1, 1)
131+
Z_PARAM_LONG(checks)
132+
ZEND_PARSE_PARAMETERS_END();
129133

130134
SPOOFCHECKER_METHOD_FETCH_OBJECT;
131135

@@ -145,9 +149,9 @@ PHP_METHOD(Spoofchecker, setRestrictionLevel)
145149
zend_long level;
146150
SPOOFCHECKER_METHOD_INIT_VARS;
147151

148-
if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS(), "l", &level)) {
149-
RETURN_THROWS();
150-
}
152+
ZEND_PARSE_PARAMETERS_START(1, 1)
153+
Z_PARAM_LONG(level)
154+
ZEND_PARSE_PARAMETERS_END();
151155

152156
SPOOFCHECKER_METHOD_FETCH_OBJECT;
153157

0 commit comments

Comments
 (0)