summaryrefslogtreecommitdiffstats
path: root/src/H5Shyper.c
diff options
context:
space:
mode:
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)