summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorRaymond Lu <songyulu@hdfgroup.org>2011-05-24 22:02:29 (GMT)
committerRaymond Lu <songyulu@hdfgroup.org>2011-05-24 22:02:29 (GMT)
commitdd23200a464417bf45d3147f503443d5c9f89ce1 (patch)
tree4ef1a21b84927a734ae7e5107e125f03ec01bef9 /src
parentcbd4ba8de162b4779c29f2482e1acc18957168d4 (diff)
downloadhdf5-dd23200a464417bf45d3147f503443d5c9f89ce1.zip
hdf5-dd23200a464417bf45d3147f503443d5c9f89ce1.tar.gz
hdf5-dd23200a464417bf45d3147f503443d5c9f89ce1.tar.bz2
[svn-r20897] I added some comments.
Tested on jam - very simple change.
Diffstat (limited to 'src')
-rw-r--r--src/H5Tconv.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/H5Tconv.c b/src/H5Tconv.c
index 927a9dc..579094a 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)