From 7a37085f0a49a595848e7629e6c16e2200b0f601 Mon Sep 17 00:00:00 2001 From: Adam Dickmeiss Date: Fri, 3 Oct 2014 15:07:03 +0200 Subject: [PATCH] Reduce ICU buffer copy for transform YAZ-790 --- include/yaz/icu_I18N.h | 3 +++ src/icu_chain.c | 4 ++++ src/icu_transform.c | 16 ++++++++++++++++ 3 files changed, 23 insertions(+) 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, -- 1.7.10.4