diff options
author | Quincey Koziol <koziol@hdfgroup.org> | 2004-04-22 20:18:53 (GMT) |
---|---|---|
committer | Quincey Koziol <koziol@hdfgroup.org> | 2004-04-22 20:18:53 (GMT) |
commit | 6010b691f953b8aeb167d694ff09b5b1f88b14b1 (patch) | |
tree | dbb0c7a07178729bbd8cea2c9cbb72722a399606 /src | |
parent | 26b7c31a6b10dd84fb94da3d906dc96f75800842 (diff) | |
download | hdf5-6010b691f953b8aeb167d694ff09b5b1f88b14b1.zip hdf5-6010b691f953b8aeb167d694ff09b5b1f88b14b1.tar.gz hdf5-6010b691f953b8aeb167d694ff09b5b1f88b14b1.tar.bz2 |
[svn-r8407] Purpose:
Code optimization
Description:
Make calculation of "all" selection sequence length information more
efficient.
Platforms tested:
Solaris 2.7 (arabica)
FreeBSD 4.9 (sleipnir)
h5comittest
Diffstat (limited to 'src')
-rw-r--r-- | src/H5Sall.c | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/src/H5Sall.c b/src/H5Sall.c index 6aae942..3708bed 100644 --- a/src/H5Sall.c +++ b/src/H5Sall.c @@ -810,8 +810,8 @@ H5S_all_get_seq_list(const H5S_t UNUSED *space, unsigned UNUSED flags, H5S_sel_i size_t elem_size, size_t UNUSED maxseq, size_t maxbytes, size_t *nseq, size_t *nbytes, hsize_t *off, size_t *len) { - hsize_t bytes_left; /* The number of bytes left in the selection */ - hsize_t elem_used; /* The number of bytes used */ + size_t max_elem; /* Maximum number of elements to use */ + size_t elem_used; /* The number of elements used */ herr_t ret_value=SUCCEED; /* return value */ FUNC_ENTER_NOAPI (H5S_all_get_seq_list, FAIL); @@ -827,16 +827,16 @@ H5S_all_get_seq_list(const H5S_t UNUSED *space, unsigned UNUSED flags, H5S_sel_i assert(off); assert(len); - /* Calculate the number of bytes left in the selection */ - bytes_left=iter->elmt_left*elem_size; + /* Detemine the maximum # of elements to use for this operation */ + max_elem=maxbytes/elem_size; - /* "round" off the maxbytes allowed to a multiple of the element size */ - maxbytes=(maxbytes/elem_size)*elem_size; + /* Determine the actual number of elements to use */ + H5_CHECK_OVERFLOW(iter->elmt_left,hsize_t,size_t); + elem_used=MIN(max_elem,(size_t)iter->elmt_left); /* Compute the offset in the dataset */ off[0]=iter->u.all.offset*elem_size; - H5_CHECK_OVERFLOW(bytes_left,hsize_t,size_t); - len[0]=MIN(maxbytes,(size_t)bytes_left); + len[0]=elem_used*elem_size; /* Should only need one sequence for 'all' selections */ *nseq=1; @@ -845,7 +845,6 @@ H5S_all_get_seq_list(const H5S_t UNUSED *space, unsigned UNUSED flags, H5S_sel_i *nbytes=len[0]; /* Update the iterator */ - elem_used=len[0]/elem_size; iter->elmt_left-=elem_used; iter->u.all.offset+=elem_used; |