Skip to content

Commit afde6dc

Browse files
committed
Simplify change_node_zval implementation
At this point, the value has already been converted into a string.
1 parent d384537 commit afde6dc

File tree

1 file changed

+6
-25
lines changed

1 file changed

+6
-25
lines changed

ext/simplexml/simplexml.c

Lines changed: 6 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -377,31 +377,12 @@ static zval *sxe_dimension_read(zend_object *object, zval *offset, int type, zva
377377
static void change_node_zval(xmlNodePtr node, zval *value)
378378
{
379379
xmlChar *buffer;
380-
381-
if (!value)
382-
{
383-
xmlNodeSetContentLen(node, (xmlChar *)"", 0);
384-
return;
385-
}
386-
switch (Z_TYPE_P(value)) {
387-
case IS_LONG:
388-
case IS_FALSE:
389-
case IS_TRUE:
390-
case IS_DOUBLE:
391-
case IS_NULL:
392-
convert_to_string(value);
393-
/* break missing intentionally */
394-
case IS_STRING:
395-
buffer = xmlEncodeEntitiesReentrant(node->doc, (xmlChar *)Z_STRVAL_P(value));
396-
/* check for NULL buffer in case of memory error in xmlEncodeEntitiesReentrant */
397-
if (buffer) {
398-
xmlNodeSetContent(node, buffer);
399-
xmlFree(buffer);
400-
}
401-
break;
402-
default:
403-
php_error_docref(NULL, E_WARNING, "It is not possible to assign complex types to nodes");
404-
break;
380+
ZEND_ASSERT(Z_TYPE_P(value) == IS_STRING);
381+
buffer = xmlEncodeEntitiesReentrant(node->doc, (xmlChar *)Z_STRVAL_P(value));
382+
/* check for NULL buffer in case of memory error in xmlEncodeEntitiesReentrant */
383+
if (buffer) {
384+
xmlNodeSetContent(node, buffer);
385+
xmlFree(buffer);
405386
}
406387
}
407388
/* }}} */

0 commit comments

Comments
 (0)