Skip to content

Commit 618e576

Browse files
committed
Minor DOM cleanups
1 parent d766a73 commit 618e576

File tree

2 files changed

+5
-21
lines changed

2 files changed

+5
-21
lines changed

ext/dom/element.c

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1210,19 +1210,17 @@ Since: DOM Level 2
12101210
*/
12111211
PHP_METHOD(DOMElement, getAttributeNodeNS)
12121212
{
1213-
zval *id;
12141213
xmlNodePtr elemp;
12151214
xmlAttrPtr attrp;
12161215
dom_object *intern;
12171216
size_t uri_len, name_len;
12181217
char *uri, *name;
12191218

1220-
id = ZEND_THIS;
12211219
if (zend_parse_parameters(ZEND_NUM_ARGS(), "s!s", &uri, &uri_len, &name, &name_len) == FAILURE) {
12221220
RETURN_THROWS();
12231221
}
12241222

1225-
DOM_GET_OBJ(elemp, id, xmlNodePtr, intern);
1223+
DOM_GET_OBJ(elemp, ZEND_THIS, xmlNodePtr, intern);
12261224

12271225
bool follow_spec = php_dom_follow_spec_intern(intern);
12281226
if (follow_spec && uri_len == 0) {
@@ -1239,16 +1237,11 @@ PHP_METHOD(DOMElement, getAttributeNodeNS)
12391237
/* Keep parent alive, because we're a fake child. */
12401238
GC_ADDREF(&intern->std);
12411239
(void) php_dom_create_fake_namespace_decl(elemp, nsptr, return_value, intern);
1242-
} else {
1243-
RETURN_NULL();
12441240
}
1245-
} else {
1246-
RETURN_NULL();
12471241
}
12481242
} else {
12491243
DOM_RET_OBJ((xmlNodePtr) attrp, intern);
12501244
}
1251-
12521245
}
12531246
/* }}} end dom_element_get_attribute_node_ns */
12541247

ext/dom/node.c

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1878,8 +1878,7 @@ static void dom_node_lookup_prefix(INTERNAL_FUNCTION_PARAMETERS, bool modern)
18781878
case XML_DOCUMENT_FRAG_NODE:
18791879
case XML_DOCUMENT_TYPE_NODE:
18801880
case XML_DTD_NODE:
1881-
RETURN_NULL();
1882-
break;
1881+
return;
18831882
default:
18841883
lookupp = nodep->parent;
18851884
}
@@ -1898,8 +1897,6 @@ static void dom_node_lookup_prefix(INTERNAL_FUNCTION_PARAMETERS, bool modern)
18981897
}
18991898
}
19001899
}
1901-
1902-
RETURN_NULL();
19031900
}
19041901

19051902
PHP_METHOD(DOMNode, lookupPrefix)
@@ -2065,16 +2062,14 @@ PHP_METHOD(DOMNode, lookupNamespaceURI)
20652062
prefix = NULL;
20662063
}
20672064
const char *ns_uri = dom_locate_a_namespace(nodep, prefix);
2068-
if (ns_uri == NULL) {
2069-
RETURN_NULL();
2070-
} else {
2065+
if (ns_uri != NULL) {
20712066
RETURN_STRING(ns_uri);
20722067
}
20732068
} else {
20742069
if (nodep->type == XML_DOCUMENT_NODE || nodep->type == XML_HTML_DOCUMENT_NODE) {
20752070
nodep = xmlDocGetRootElement((xmlDocPtr) nodep);
20762071
if (nodep == NULL) {
2077-
RETURN_NULL();
2072+
return;
20782073
}
20792074
}
20802075

@@ -2083,8 +2078,6 @@ PHP_METHOD(DOMNode, lookupNamespaceURI)
20832078
RETURN_STRING((char *) nsptr->href);
20842079
}
20852080
}
2086-
2087-
RETURN_NULL();
20882081
}
20892082
/* }}} end dom_node_lookup_namespace_uri */
20902083

@@ -2294,21 +2287,19 @@ static void dom_node_get_node_path(INTERNAL_FUNCTION_PARAMETERS, bool throw)
22942287
zval *id;
22952288
xmlNode *nodep;
22962289
dom_object *intern;
2297-
char *value;
22982290

22992291
ZEND_PARSE_PARAMETERS_NONE();
23002292

23012293
DOM_GET_THIS_OBJ(nodep, id, xmlNodePtr, intern);
23022294

2303-
value = (char *) xmlGetNodePath(nodep);
2295+
char *value = (char *) xmlGetNodePath(nodep);
23042296
if (value == NULL) {
23052297
/* This is only possible when an invalid argument is passed (e.g. namespace declaration, but that's not the case for this call site),
23062298
* or on allocation failure. So in other words, this only happens on allocation failure. */
23072299
if (throw) {
23082300
php_dom_throw_error(INVALID_STATE_ERR, /* strict */ true);
23092301
RETURN_THROWS();
23102302
}
2311-
RETURN_NULL();
23122303
} else {
23132304
RETVAL_STRING(value);
23142305
xmlFree(value);

0 commit comments

Comments
 (0)