From: Adam Dickmeiss Date: Fri, 3 Oct 2014 13:07:03 +0000 (+0200) Subject: Reduce ICU buffer copy for transform YAZ-790 X-Git-Url: http://jsfdemo.indexdata.com/cgi-bin?a=commitdiff_plain;h=refs%2Fheads%2Fyaz-790;p=yaz-moved-to-github.git Reduce ICU buffer copy for transform YAZ-790 --- diff --git a/include/yaz/icu_I18N.h b/include/yaz/icu_I18N.h index c570384..e0d8f06 100644 --- a/include/yaz/icu_I18N.h +++ b/include/yaz/icu_I18N.h @@ -156,6 +156,9 @@ int icu_transform_trans(struct icu_transform *transform, struct icu_buf_utf16 *dest16, const struct icu_buf_utf16 *src16, UErrorCode *status); +void icu_transform_trans2(struct icu_transform *transform, + struct icu_buf_utf16 *dest16, + UErrorCode *status); struct icu_chain_step; diff --git a/src/icu_chain.c b/src/icu_chain.c index b672975..c0af393 100644 --- a/src/icu_chain.c +++ b/src/icu_chain.c @@ -441,10 +441,14 @@ struct icu_buf_utf16 *icu_iter_invoke(yaz_icu_iter_t iter, case ICU_chain_step_type_transliterate: if (dst) { +#if 1 + icu_transform_trans2(step->u.transform, dst, &iter->status); +#else struct icu_buf_utf16 *src = dst; dst = icu_buf_utf16_create(0); icu_transform_trans(step->u.transform, dst, src, &iter->status); icu_buf_utf16_destroy(src); +#endif } break; case ICU_chain_step_type_display: diff --git a/src/icu_transform.c b/src/icu_transform.c index 8e68ba9..e18249a 100644 --- a/src/icu_transform.c +++ b/src/icu_transform.c @@ -112,6 +112,22 @@ void icu_transform_destroy(struct icu_transform *transform) } } +void icu_transform_trans2(struct icu_transform *transform, + struct icu_buf_utf16 *dest16, + UErrorCode *status) +{ + assert(transform); + assert(dest16); + + if (!dest16->utf16) + return; + + utrans_transUChars(transform->trans, + dest16->utf16, &(dest16->utf16_len), + dest16->utf16_cap, + 0, &(dest16->utf16_len), status); +} + int icu_transform_trans(struct icu_transform *transform, struct icu_buf_utf16 *dest16, const struct icu_buf_utf16 *src16,