diff options
author | Quincey Koziol <koziol@hdfgroup.org> | 2005-06-02 16:02:02 (GMT) |
---|---|---|
committer | Quincey Koziol <koziol@hdfgroup.org> | 2005-06-02 16:02:02 (GMT) |
commit | 62af6baea1e8cb75a1034b11676455f8f6c1ff42 (patch) | |
tree | 30f6ded967b04506d551d223f35a13ad9be62d9d /src | |
parent | b9a453510d6facab51fce549734ba29d5bd79fc0 (diff) | |
download | hdf5-62af6baea1e8cb75a1034b11676455f8f6c1ff42.zip hdf5-62af6baea1e8cb75a1034b11676455f8f6c1ff42.tar.gz hdf5-62af6baea1e8cb75a1034b11676455f8f6c1ff42.tar.bz2 |
[svn-r10844] Purpose:
Code cleanup
Description:
Simplify the "zero-sized hyperslab" handling.
Platforms tested:
FreeBSD 4.11 (sleipnir)
Too minor to require h5committest
Misc. update:
Diffstat (limited to 'src')
-rw-r--r-- | src/H5Shyper.c | 86 |
1 files changed, 38 insertions, 48 deletions
diff --git a/src/H5Shyper.c b/src/H5Shyper.c index faecd30..6f8c1d1 100644 --- a/src/H5Shyper.c +++ b/src/H5Shyper.c @@ -5729,7 +5729,6 @@ H5S_select_hyperslab (H5S_t *space, H5S_seloper_t op, const hsize_t *opt_stride; /* Optimized stride information */ const hsize_t *opt_count; /* Optimized count information */ const hsize_t *opt_block; /* Optimized block information */ - hbool_t zero_hyperslab = FALSE; /* Indicate if the new hyperslab contains zero elements */ unsigned u; /* Counters */ herr_t ret_value=SUCCEED; /* Return value */ @@ -5758,8 +5757,25 @@ H5S_select_hyperslab (H5S_t *space, H5S_seloper_t op, HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "hyperslab blocks overlap"); /* Detect zero-sized hyperslabs in new selection */ - if(count[u] == 0 || block[u] == 0) - zero_hyperslab = TRUE; + if(count[u] == 0 || block[u] == 0) { + switch(op) { + case H5S_SELECT_SET: /* Select "set" operation */ + case H5S_SELECT_AND: /* Binary "and" operation for hyperslabs */ + case H5S_SELECT_NOTA: /* Binary "B not A" operation for hyperslabs */ + /* Convert to "none" selection */ + if(H5S_select_none(space)<0) + HGOTO_ERROR(H5E_DATASPACE, H5E_CANTDELETE, FAIL, "can't convert selection"); + HGOTO_DONE(SUCCEED); + + case H5S_SELECT_OR: /* Binary "or" operation for hyperslabs */ + case H5S_SELECT_XOR: /* Binary "xor" operation for hyperslabs */ + case H5S_SELECT_NOTB: /* Binary "A not B" operation for hyperslabs */ + HGOTO_DONE(SUCCEED); /* Selection stays same */ + + default: + HGOTO_ERROR(H5E_ARGS, H5E_UNSUPPORTED, FAIL, "invalid selection operation"); + } /* end switch */ + } /* end if */ } /* end for */ /* Optimize hyperslab parameters to merge contiguous blocks, etc. */ @@ -5797,27 +5813,6 @@ H5S_select_hyperslab (H5S_t *space, H5S_seloper_t op, } /* end for */ } /* end else */ - /* Fixup zero-sized hyperslab selections */ - if(zero_hyperslab) { - switch(op) { - case H5S_SELECT_SET: /* Select "set" operation */ - case H5S_SELECT_AND: /* Binary "and" operation for hyperslabs */ - case H5S_SELECT_NOTA: /* Binary "B not A" operation for hyperslabs */ - /* Convert to "none" selection */ - if(H5S_select_none(space)<0) - HGOTO_ERROR(H5E_DATASPACE, H5E_CANTDELETE, FAIL, "can't convert selection"); - HGOTO_DONE(SUCCEED); - - case H5S_SELECT_OR: /* Binary "or" operation for hyperslabs */ - case H5S_SELECT_XOR: /* Binary "xor" operation for hyperslabs */ - case H5S_SELECT_NOTB: /* Binary "A not B" operation for hyperslabs */ - HGOTO_DONE(SUCCEED); /* Selection stays same */ - - default: - HGOTO_ERROR(H5E_ARGS, H5E_UNSUPPORTED, FAIL, "invalid selection operation"); - } /* end switch */ - } /* end if */ - /* Fixup operation for non-hyperslab selections */ switch(H5S_GET_SELECT_TYPE(space)) { case H5S_SEL_NONE: /* No elements selected in dataspace */ @@ -6334,7 +6329,6 @@ H5S_select_hyperslab (H5S_t *space, H5S_seloper_t op, const hsize_t *opt_stride; /* Optimized stride information */ const hsize_t *opt_count; /* Optimized count information */ const hsize_t *opt_block; /* Optimized block information */ - hbool_t zero_hyperslab = FALSE; /* Indicate if the new hyperslab contains zero elements */ unsigned u; /* Counters */ herr_t ret_value=SUCCEED; /* Return value */ @@ -6363,8 +6357,25 @@ H5S_select_hyperslab (H5S_t *space, H5S_seloper_t op, HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "hyperslab blocks overlap"); /* Detect zero-sized hyperslabs in new selection */ - if(count[u] == 0 || block[u] == 0) - zero_hyperslab = TRUE; + if(count[u] == 0 || block[u] == 0) { + switch(op) { + case H5S_SELECT_SET: /* Select "set" operation */ + case H5S_SELECT_AND: /* Binary "and" operation for hyperslabs */ + case H5S_SELECT_NOTA: /* Binary "B not A" operation for hyperslabs */ + /* Convert to "none" selection */ + if(H5S_select_none(space)<0) + HGOTO_ERROR(H5E_DATASPACE, H5E_CANTDELETE, FAIL, "can't convert selection"); + HGOTO_DONE(SUCCEED); + + case H5S_SELECT_OR: /* Binary "or" operation for hyperslabs */ + case H5S_SELECT_XOR: /* Binary "xor" operation for hyperslabs */ + case H5S_SELECT_NOTB: /* Binary "A not B" operation for hyperslabs */ + HGOTO_DONE(SUCCEED); /* Selection stays same */ + + default: + HGOTO_ERROR(H5E_ARGS, H5E_UNSUPPORTED, FAIL, "invalid selection operation"); + } /* end switch */ + } /* end if */ } /* end for */ /* Optimize hyperslab parameters to merge contiguous blocks, etc. */ @@ -6402,27 +6413,6 @@ H5S_select_hyperslab (H5S_t *space, H5S_seloper_t op, } /* end for */ } /* end else */ - /* Fixup zero-sized hyperslab selections */ - if(zero_hyperslab) { - switch(op) { - case H5S_SELECT_SET: /* Select "set" operation */ - case H5S_SELECT_AND: /* Binary "and" operation for hyperslabs */ - case H5S_SELECT_NOTA: /* Binary "B not A" operation for hyperslabs */ - /* Convert to "none" selection */ - if(H5S_select_none(space)<0) - HGOTO_ERROR(H5E_DATASPACE, H5E_CANTDELETE, FAIL, "can't convert selection"); - HGOTO_DONE(SUCCEED); - - case H5S_SELECT_OR: /* Binary "or" operation for hyperslabs */ - case H5S_SELECT_XOR: /* Binary "xor" operation for hyperslabs */ - case H5S_SELECT_NOTB: /* Binary "A not B" operation for hyperslabs */ - HGOTO_DONE(SUCCEED); /* Selection stays same */ - - default: - HGOTO_ERROR(H5E_ARGS, H5E_UNSUPPORTED, FAIL, "invalid selection operation"); - } /* end switch */ - } /* end if */ - /* Fixup operation for non-hyperslab selections */ switch(H5S_GET_SELECT_TYPE(space)) { case H5S_SEL_NONE: /* No elements selected in dataspace */ |