This is an automated email from the ASF dual-hosted git repository. kgiusti pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/qpid-dispatch.git
The following commit(s) were added to refs/heads/main by this push: new 607b751 DISPATCH-2251: simple optimization of qd_compose_insert_string_iterator 607b751 is described below commit 607b75106a049dc98867beb858d2ac1d556c4855 Author: Kenneth Giusti <kgiu...@apache.org> AuthorDate: Tue Sep 21 11:07:06 2021 -0400 DISPATCH-2251: simple optimization of qd_compose_insert_string_iterator This closes #1374 --- src/compose.c | 25 ++++--------------------- 1 file changed, 4 insertions(+), 21 deletions(-) diff --git a/src/compose.c b/src/compose.c index 9b59669..8f42f54 100644 --- a/src/compose.c +++ b/src/compose.c @@ -472,29 +472,12 @@ void qd_compose_insert_string2(qd_composed_field_t *field, const char *value1, c void qd_compose_insert_string_iterator(qd_composed_field_t *field, qd_iterator_t *iter) { - uint32_t len = 0; - qd_iterator_reset(iter); - while (!qd_iterator_end(iter)) { - qd_iterator_octet(iter); - len++; - } - qd_iterator_reset(iter); - if (len < 256) { - qd_insert_8(field, QD_AMQP_STR8_UTF8); - qd_insert_8(field, (uint8_t) len); - } else { - qd_insert_8(field, QD_AMQP_STR32_UTF8); - qd_insert_32(field, len); - } - - while (!qd_iterator_end(iter)) { - uint8_t octet = qd_iterator_octet(iter); - qd_insert_8(field, octet); - } - - bump_count(field); + char *as_str = (char *)qd_iterator_copy(iter); + const uint32_t len = as_str ? strlen(as_str) : 0; + qd_compose_insert_string_n(field, as_str, len); + free(as_str); } --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@qpid.apache.org For additional commands, e-mail: commits-h...@qpid.apache.org