diff options
author | Raymond Lu <songyulu@hdfgroup.org> | 2011-05-24 21:51:41 (GMT) |
---|---|---|
committer | Raymond Lu <songyulu@hdfgroup.org> | 2011-05-24 21:51:41 (GMT) |
commit | 48dc2ca2fc8bd929401c56908c4daf1b922e8d0e (patch) | |
tree | 5857a73bf417b7e66a5103f246440d68d9f14a3e /src/H5Tconv.c | |
parent | 0418b80b226e22db0b8ddbfcd3754a90c8eb54f9 (diff) | |
download | hdf5-48dc2ca2fc8bd929401c56908c4daf1b922e8d0e.zip hdf5-48dc2ca2fc8bd929401c56908c4daf1b922e8d0e.tar.gz hdf5-48dc2ca2fc8bd929401c56908c4daf1b922e8d0e.tar.bz2 |
[svn-r20896] I added some comments.
Tested on jam - very simple change.
Diffstat (limited to 'src/H5Tconv.c')
-rw-r--r-- | src/H5Tconv.c | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/src/H5Tconv.c b/src/H5Tconv.c index 927a9dc..e7295d7 100644 --- a/src/H5Tconv.c +++ b/src/H5Tconv.c @@ -2614,6 +2614,15 @@ H5T_conv_enum_init(H5T_t *src, H5T_t *dst, H5T_cdata_t *cdata) * a native integer type as an index into the `val2dst'. The values of * that array are the index numbers in the destination type or negative * if the entry is unused. + * + * (This optimized algorithm doesn't work when the byte orders are different. + * The code such as "n = *((int*)(src->shared->u.enumer.value+i*src->shared->size));" + * can change the value significantly. i.g. if the source value is big-endian 0x0000000f, + * executing the casting on little-endian machine will get a big number 0x0f000000. + * Then it can't meet the condition + * "if(src->shared->u.enumer.nmembs<2 || (double)length/src->shared->u.enumer.nmembs<1.2)" + * Because this is the optimized code, we won't fix it. It should still work in some + * situations. SLU - 2011/5/24) */ if (1==src->shared->size || sizeof(short)==src->shared->size || sizeof(int)==src->shared->size) { for (i=0; i<src->shared->u.enumer.nmembs; i++) { @@ -2796,6 +2805,12 @@ H5T_conv_enum(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, for(i = 0; i < nelmts; i++, s += src_delta, d += dst_delta) { if(priv->length) { /* Use O(1) lookup */ + /* (The casting won't work when the byte orders are different. i.g. if the source value + * is big-endian 0x0000000f, the direct casting "n = *((int*)s);" will make it a big + * number 0x0f000000 on little-endian machine. But we won't fix it because it's an + * optimization code. Please also see the comment in the H5T_conv_enum_init() function. + * SLU - 2011/5/24) + */ if(1 == src->shared->size) n = *((signed char*)s); else if(sizeof(short) == src->shared->size) |