Skip to content

Commit b21c169

Browse files
authored
Convert more commonly used DOM element methods to use fast ZPP (php#17357)
1 parent c7a322c commit b21c169

File tree

1 file changed

+17
-24
lines changed

1 file changed

+17
-24
lines changed

ext/dom/element.c

Lines changed: 17 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,6 @@ Modern spec URL: https://dom.spec.whatwg.org/#dom-element-getattribute
291291
*/
292292
PHP_METHOD(DOMElement, getAttribute)
293293
{
294-
zval *id;
295294
xmlNode *nodep;
296295
char *name;
297296
xmlChar *value = NULL;
@@ -300,12 +299,11 @@ PHP_METHOD(DOMElement, getAttribute)
300299
size_t name_len;
301300
bool should_free = false;
302301

303-
id = ZEND_THIS;
304-
if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &name, &name_len) == FAILURE) {
305-
RETURN_THROWS();
306-
}
302+
ZEND_PARSE_PARAMETERS_START(1, 1)
303+
Z_PARAM_STRING(name, name_len)
304+
ZEND_PARSE_PARAMETERS_END();
307305

308-
DOM_GET_OBJ(nodep, id, xmlNodePtr, intern);
306+
DOM_GET_OBJ(nodep, ZEND_THIS, xmlNodePtr, intern);
309307

310308
attr = dom_get_attribute_or_nsdecl(intern, nodep, BAD_CAST name, name_len);
311309
if (attr) {
@@ -348,9 +346,7 @@ PHP_METHOD(DOMElement, getAttributeNames)
348346
dom_object *intern;
349347
zval tmp;
350348

351-
if (zend_parse_parameters_none() == FAILURE) {
352-
RETURN_THROWS();
353-
}
349+
ZEND_PARSE_PARAMETERS_NONE();
354350

355351
DOM_GET_THIS_OBJ(nodep, id, xmlNodePtr, intern);
356352

@@ -402,17 +398,16 @@ Modern spec URL: https://dom.spec.whatwg.org/#dom-element-setattribute
402398
*/
403399
PHP_METHOD(DOMElement, setAttribute)
404400
{
405-
zval *id;
406401
xmlNode *nodep;
407402
int name_valid;
408403
size_t name_len, value_len;
409404
dom_object *intern;
410405
char *name, *value;
411406

412-
id = ZEND_THIS;
413-
if (zend_parse_parameters(ZEND_NUM_ARGS(), "ss", &name, &name_len, &value, &value_len) == FAILURE) {
414-
RETURN_THROWS();
415-
}
407+
ZEND_PARSE_PARAMETERS_START(2, 2)
408+
Z_PARAM_STRING(name, name_len)
409+
Z_PARAM_STRING(value, value_len)
410+
ZEND_PARSE_PARAMETERS_END();
416411

417412
if (name_len == 0) {
418413
zend_argument_must_not_be_empty_error(1);
@@ -425,7 +420,7 @@ PHP_METHOD(DOMElement, setAttribute)
425420
RETURN_THROWS();
426421
}
427422

428-
DOM_GET_OBJ(nodep, id, xmlNodePtr, intern);
423+
DOM_GET_OBJ(nodep, ZEND_THIS, xmlNodePtr, intern);
429424

430425
if (php_dom_follow_spec_intern(intern)) {
431426
xmlChar *name_processed = BAD_CAST name;
@@ -646,18 +641,16 @@ Modern spec URL: https://dom.spec.whatwg.org/#dom-element-getattributenode
646641
*/
647642
PHP_METHOD(DOMElement, getAttributeNode)
648643
{
649-
zval *id;
650644
xmlNodePtr nodep, attrp;
651645
size_t name_len;
652646
dom_object *intern;
653647
char *name;
654648

655-
id = ZEND_THIS;
656-
if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &name, &name_len) == FAILURE) {
657-
RETURN_THROWS();
658-
}
649+
ZEND_PARSE_PARAMETERS_START(1, 1)
650+
Z_PARAM_STRING(name, name_len)
651+
ZEND_PARSE_PARAMETERS_END();
659652

660-
DOM_GET_OBJ(nodep, id, xmlNodePtr, intern);
653+
DOM_GET_OBJ(nodep, ZEND_THIS, xmlNodePtr, intern);
661654

662655
attrp = dom_get_attribute_or_nsdecl(intern, nodep, BAD_CAST name, name_len);
663656
if (attrp == NULL) {
@@ -774,9 +767,9 @@ static void dom_element_remove_attribute_node(INTERNAL_FUNCTION_PARAMETERS, zend
774767
xmlAttr *attrp;
775768
dom_object *intern, *attrobj;
776769

777-
if (zend_parse_parameters(ZEND_NUM_ARGS(), "O", &node, node_ce) == FAILURE) {
778-
RETURN_THROWS();
779-
}
770+
ZEND_PARSE_PARAMETERS_START(1, 1)
771+
Z_PARAM_OBJECT_OF_CLASS(node, node_ce)
772+
ZEND_PARSE_PARAMETERS_END();
780773

781774
DOM_GET_OBJ(nodep, ZEND_THIS, xmlNodePtr, intern);
782775

0 commit comments

Comments
 (0)