# small patch for implode() function

- Thread: https://externals.io/message/10875
- Original archive: https://news-web.php.net/php.internals/10875
- Started by Alexander Valyalkin on 2004-07-02T16:30:47+00:00
- Messages: 1
- Reply by email to internals@lists.php.net
- More for agents: search with https://externals.io/search.md?q={query} · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

---

## #10875 — Alexander Valyalkin — 2004-07-02T16:30:47+00:00

URL: https://externals.io/message/10875#10875

there is such code in the php_implode() function:
[snip]
     while (zend_hash_get_current_data_ex(Z_ARRVAL_P(arr),
                                          (void **) &tmp,
                                          &pos) == SUCCESS) {
         SEPARATE_ZVAL(tmp);
         convert_to_string(*tmp);
[snip]

SEPARATE_ZVAL() always duplicates data of the tmp, even
Z_TYPE_PP(tmp) == IS_STRING.
It is terrible slowdowns the `implode()` function.
So, changing the strings
     SEPARATE_ZVAL(tmp);
     convert_to_string(*tmp);

to
     convert_to_string_ex(tmp);

will increase speed twice, because most of elements in the imploding
array has IS_STRING type.


-- 
Using Opera's revolutionary e-mail client: http://www.opera.com/m2/
