"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "bench/icu.c" between
utf8proc-2.4.0.tar.gz and utf8proc-2.5.0.tar.gz

About: utf8proc is a clean C library for processing UTF-8 Unicode data: normalization, case-folding, graphemes, and other operations.

icu.c  (utf8proc-2.4.0):icu.c  (utf8proc-2.5.0)
skipping to change at line 44 skipping to change at line 44
} }
/* convert UTF8 data to ICU's UTF16 */ /* convert UTF8 data to ICU's UTF16 */
UChar *usrc = (UChar*) malloc(2*len * sizeof(UChar)); UChar *usrc = (UChar*) malloc(2*len * sizeof(UChar));
ucnv_toUChars(uc, usrc, 2*len, (char*) src, len, &err); ucnv_toUChars(uc, usrc, 2*len, (char*) src, len, &err);
if (U_FAILURE(err)) return EXIT_FAILURE; if (U_FAILURE(err)) return EXIT_FAILURE;
size_t ulen = u_strlen(usrc); size_t ulen = u_strlen(usrc);
/* ICU's insane normalization API requires you to /* ICU's insane normalization API requires you to
know the size of the destination buffer in advance, know the size of the destination buffer in advance,
or alternatively to repeatly try normalizing and or alternatively to repeatedly try normalizing and
double the buffer size until it succeeds. Here, I just double the buffer size until it succeeds. Here, I just
allocate a huge destination buffer to avoid the issue. * / allocate a huge destination buffer to avoid the issue. * /
UChar *udest = (UChar*) malloc(10*ulen * sizeof(UChar)); UChar *udest = (UChar*) malloc(10*ulen * sizeof(UChar));
mytime start = gettime(); mytime start = gettime();
for (int i = 0; i < 100; ++i) { for (int i = 0; i < 100; ++i) {
unorm2_normalize(NFKC, usrc, ulen, udest, 10*ulen, &er r); unorm2_normalize(NFKC, usrc, ulen, udest, 10*ulen, &er r);
if (U_FAILURE(err)) return EXIT_FAILURE; if (U_FAILURE(err)) return EXIT_FAILURE;
} }
printf("%s: %g\n", argv[i], elapsed(gettime(), start) / 100); printf("%s: %g\n", argv[i], elapsed(gettime(), start) / 100);
 End of changes. 1 change blocks. 
1 lines changed or deleted 1 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)