summaryrefslogtreecommitdiffstats
path: root/src/H5Shyper.c
diff options
context:
space:
mode:
authorNeil Fortner <nfortne2@hdfgroup.org>2019-11-18 19:33:36 (GMT)
committerNeil Fortner <nfortne2@hdfgroup.org>2019-11-18 19:33:36 (GMT)
commit4e12984b77cdd7615843d94f8de8d54db27476ac (patch)
tree7db096e4acbf035781fefbcb1e6868e4ec0ccfed /src/H5Shyper.c
parent4064332a2dc45e591666ce1bff02001239009bb8 (diff)
downloadhdf5-4e12984b77cdd7615843d94f8de8d54db27476ac.zip
hdf5-4e12984b77cdd7615843d94f8de8d54db27476ac.tar.gz
hdf5-4e12984b77cdd7615843d94f8de8d54db27476ac.tar.bz2
Move checking for zero offset in selection adjust calls to the selection callbacks. This makes the
procedure for checking it consistent across selection types and between _s and _u, ensures it is always is performed even when called within the H5S package, and removes the redundant check that would occur when callins H5S_select_adjust_s() from outside the H5S package.
Diffstat (limited to 'src/H5Shyper.c')
-rw-r--r--src/H5Shyper.c55
1 files changed, 33 insertions, 22 deletions
diff --git a/src/H5Shyper.c b/src/H5Shyper.c
index a76812d..ab06eff 100644
--- a/src/H5Shyper.c
+++ b/src/H5Shyper.c
@@ -6477,39 +6477,50 @@ H5S__hyper_adjust_u_helper(H5S_hyper_span_info_t *spans, unsigned rank,
static herr_t
H5S__hyper_adjust_u(H5S_t *space, const hsize_t *offset)
{
+ hbool_t non_zero_offset = FALSE; /* Whether any offset is non-zero */
+ unsigned u; /* Local index variable */
+
FUNC_ENTER_STATIC_NOERR
/* Sanity check */
HDassert(space);
HDassert(offset);
- /* Subtract the offset from the "regular" coordinates, if they exist */
- /* (No need to rebuild the dimension info yet -QAK) */
- if(space->select.sel_info.hslab->diminfo_valid == H5S_DIMINFO_VALID_YES) {
- unsigned u; /* Local index variable */
+ /* Check for an all-zero offset vector */
+ for(u = 0; u < space->extent.rank; u++)
+ if(0 != offset[u]) {
+ non_zero_offset = TRUE;
+ break;
+ } /* end if */
- for(u = 0; u < space->extent.rank; u++) {
- HDassert(space->select.sel_info.hslab->diminfo.opt[u].start >= offset[u]);
- space->select.sel_info.hslab->diminfo.opt[u].start -= offset[u];
+ /* Only perform operation if the offset is non-zero */
+ if(non_zero_offset) {
+ /* Subtract the offset from the "regular" coordinates, if they exist */
+ /* (No need to rebuild the dimension info yet -QAK) */
+ if(space->select.sel_info.hslab->diminfo_valid == H5S_DIMINFO_VALID_YES) {
+ for(u = 0; u < space->extent.rank; u++) {
+ HDassert(space->select.sel_info.hslab->diminfo.opt[u].start >= offset[u]);
+ space->select.sel_info.hslab->diminfo.opt[u].start -= offset[u];
- /* Adjust the low & high bounds */
- HDassert(space->select.sel_info.hslab->diminfo.low_bounds[u] >= offset[u]);
- space->select.sel_info.hslab->diminfo.low_bounds[u] -= offset[u];
- space->select.sel_info.hslab->diminfo.high_bounds[u] -= offset[u];
- } /* end for */
- } /* end if */
+ /* Adjust the low & high bounds */
+ HDassert(space->select.sel_info.hslab->diminfo.low_bounds[u] >= offset[u]);
+ space->select.sel_info.hslab->diminfo.low_bounds[u] -= offset[u];
+ space->select.sel_info.hslab->diminfo.high_bounds[u] -= offset[u];
+ } /* end for */
+ } /* end if */
- /* Subtract the offset from the span tree coordinates, if they exist */
- if(space->select.sel_info.hslab->span_lst) {
- uint64_t op_gen; /* Operation generation value */
+ /* Subtract the offset from the span tree coordinates, if they exist */
+ if(space->select.sel_info.hslab->span_lst) {
+ uint64_t op_gen; /* Operation generation value */
- /* Acquire an operation generation value for this operation */
- op_gen = H5S__hyper_get_op_gen();
+ /* Acquire an operation generation value for this operation */
+ op_gen = H5S__hyper_get_op_gen();
- /* Perform adjustment */
- /* Always use op_info[0] since we own this op_info, so there can be no
- * simultaneous operations */
- H5S__hyper_adjust_u_helper(space->select.sel_info.hslab->span_lst, space->extent.rank, offset, 0, op_gen);
+ /* Perform adjustment */
+ /* Always use op_info[0] since we own this op_info, so there can be no
+ * simultaneous operations */
+ H5S__hyper_adjust_u_helper(space->select.sel_info.hslab->span_lst, space->extent.rank, offset, 0, op_gen);
+ } /* end if */
} /* end if */
FUNC_LEAVE_NOAPI(SUCCEED)