From c0c6e9944f749c791f64656e879f410f2b3016cf Mon Sep 17 00:00:00 2001 From: Rasmus Lerdorf Date: Thu, 15 Jun 2006 18:03:30 +0000 Subject: [PATCH] I don't think the call to xmlNodeSetContentLen() is needed here and it is causing performance problems because it tries to parse the blob and create a subtree. Because we are escaping the string anyway, we are never going to get a subtree, but the entity parsing that is done by xmlNodeSetContentLen() is killing performance on large blobs of text. On one recent example it took a couple of minutes to parse whereas if we just create a text node like this and set the contents to the raw string it is down to milliseconds. As far as I can tell all the tests pass with this patch. --- ext/soap/php_encoding.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/ext/soap/php_encoding.c b/ext/soap/php_encoding.c index 0a7af83483..9abb704ce8 100644 --- a/ext/soap/php_encoding.c +++ b/ext/soap/php_encoding.c @@ -728,7 +728,7 @@ static zval *to_zval_hexbin(encodeTypePtr type, xmlNodePtr data) static xmlNodePtr to_xml_string(encodeTypePtr type, zval *data, int style, xmlNodePtr parent) { - xmlNodePtr ret; + xmlNodePtr ret, text; char *str; int new_len; TSRMLS_FETCH(); @@ -738,13 +738,15 @@ static xmlNodePtr to_xml_string(encodeTypePtr type, zval *data, int style, xmlNo FIND_ZVAL_NULL(data, ret, style); if (Z_TYPE_P(data) == IS_STRING) { - str = php_escape_html_entities(Z_STRVAL_P(data), Z_STRLEN_P(data), &new_len, 0, 0, NULL TSRMLS_CC); + str = estrndup(Z_STRVAL_P(data), Z_STRLEN_P(data)); + new_len = Z_STRLEN_P(data); } else { zval tmp = *data; zval_copy_ctor(&tmp); convert_to_string(&tmp); - str = php_escape_html_entities(Z_STRVAL(tmp), Z_STRLEN(tmp), &new_len, 0, 0, NULL TSRMLS_CC); + str = estrndup(Z_STRVAL(tmp), Z_STRLEN(tmp)); + new_len = Z_STRLEN(tmp); zval_dtor(&tmp); } @@ -766,7 +768,8 @@ static xmlNodePtr to_xml_string(encodeTypePtr type, zval *data, int style, xmlNo soap_error1(E_ERROR, "Encoding: string '%s' is not a valid utf-8 string", str); } - xmlNodeSetContentLen(ret, str, new_len); + text = xmlNewTextLen(str, new_len); + xmlAddChild(ret, text); efree(str); if (style == SOAP_ENCODED) { -- 2.50.1