Reduce ICU buffer copy for transform YAZ-790 yaz-790
authorAdam Dickmeiss <adam@indexdata.dk>
Fri, 3 Oct 2014 13:07:03 +0000 (15:07 +0200)
committerAdam Dickmeiss <adam@indexdata.dk>
Fri, 3 Oct 2014 13:07:03 +0000 (15:07 +0200)
include/yaz/icu_I18N.h
src/icu_chain.c
src/icu_transform.c

index c570384..e0d8f06 100644 (file)
@@ -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;
 
index b672975..c0af393 100644 (file)
@@ -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:
index 8e68ba9..e18249a 100644 (file)
@@ -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,