From: Adam Dickmeiss Date: Wed, 25 Jun 2014 13:04:06 +0000 (+0200) Subject: Optimize speed of icu_iter_get_org_info X-Git-Tag: v5.2.1~3 X-Git-Url: http://sru.miketaylor.org.uk/cgi-bin?a=commitdiff_plain;h=e9f1f9fae5dd16e2016bf6988631d8111b3c0980;p=yaz-moved-to-github.git Optimize speed of icu_iter_get_org_info In particular, reduce calls to u_strToUTF8. --- diff --git a/src/icu_chain.c b/src/icu_chain.c index 6aac1c0..0cf7925 100644 --- a/src/icu_chain.c +++ b/src/icu_chain.c @@ -566,26 +566,16 @@ int icu_iter_get_token_number(yaz_icu_iter_t iter) void icu_iter_get_org_info(yaz_icu_iter_t iter, size_t *start, size_t *len) { - /* save full length of org since we're gonna cut it */ - int32_t save_len = iter->org->utf16_len; - - struct icu_buf_utf8 *tmp = icu_buf_utf8_create(0); + int32_t len1 = 0, len2 = 0; UErrorCode status = U_ZERO_ERROR; - iter->org->utf16_len = iter->org_start; - icu_utf16_to_utf8(tmp, iter->org, &status); - if (U_SUCCESS(status)) - *start = tmp->utf8_len; - else - *start = 0; - iter->org->utf16_len = iter->org_start + iter->org_len; - icu_utf16_to_utf8(tmp, iter->org, &status); - if (U_SUCCESS(status)) - *len = tmp->utf8_len - *start; - else - *len = 0; - icu_buf_utf8_destroy(tmp); - iter->org->utf16_len = save_len; + u_strToUTF8(0, 0, &len1, iter->org->utf16, iter->org_start, + &status); + status = U_ZERO_ERROR; + u_strToUTF8(0, 0, &len2, iter->org->utf16 + iter->org_start, iter->org_len, + &status); + *start = len1; + *len = len2; } int icu_chain_assign_cstr(struct icu_chain *chain, const char *src8cstr,