diff options
author | Quincey Koziol <koziol@hdfgroup.org> | 2002-08-08 16:52:55 (GMT) |
---|---|---|
committer | Quincey Koziol <koziol@hdfgroup.org> | 2002-08-08 16:52:55 (GMT) |
commit | d8397a6f426227d09d20e647ce8b12b8c6295b2d (patch) | |
tree | 2943fbfd2bfb66cf167eb642835fdb4deb3afd3c /src/H5Vprivate.h | |
parent | 573307786a1f5f7ce597e5191ea08c3bbd95b66c (diff) | |
download | hdf5-d8397a6f426227d09d20e647ce8b12b8c6295b2d.zip hdf5-d8397a6f426227d09d20e647ce8b12b8c6295b2d.tar.gz hdf5-d8397a6f426227d09d20e647ce8b12b8c6295b2d.tar.bz2 |
[svn-r5842] Purpose:
Code cleanup
Description:
Change most (all?) HRETURN_ERROR macros to HGOTO_ERROR macros, along with
HRETURN macros to HGOTO_DONE macros. This unifies the error return path
from functions and reduces the size of the library by up to 10% on some
platforms.
Additionally, I improved a lot of the error cleanup code in many routines.
Platforms tested:
FreeBSD 4.6 (sleipnir) serial & parallel and IRIX64 6.5 (modi4) serial &
parallel.
Diffstat (limited to 'src/H5Vprivate.h')
-rw-r--r-- | src/H5Vprivate.h | 64 |
1 files changed, 42 insertions, 22 deletions
diff --git a/src/H5Vprivate.h b/src/H5Vprivate.h index 156e6bd..ffc17dc 100644 --- a/src/H5Vprivate.h +++ b/src/H5Vprivate.h @@ -98,14 +98,16 @@ __DLL__ hsize_t H5V_array_offset(unsigned n, const hsize_t *total_size, static H5_inline hsize_t H5V_vector_reduce_product(unsigned n, const hsize_t *v) { - hsize_t ans = 1; + hsize_t ret_value = 1; /* Use FUNC_ENTER_NOINIT here to avoid performance issues */ FUNC_ENTER_NOINIT(H5V_vector_reduce_product); - if (n && !v) HRETURN(0); - while (n--) ans *= *v++; - FUNC_LEAVE(ans); + if (n && !v) HGOTO_DONE(0); + while (n--) ret_value *= *v++; + +done: + FUNC_LEAVE(ret_value); } /*------------------------------------------------------------------------- @@ -128,14 +130,19 @@ H5V_vector_reduce_product(unsigned n, const hsize_t *v) static H5_inline htri_t UNUSED H5V_vector_zerop_u(int n, const hsize_t *v) { + htri_t ret_value=TRUE; /* Return value */ + /* Use FUNC_ENTER_NOINIT here to avoid performance issues */ FUNC_ENTER_NOINIT(H5V_vector_zerop_u); - if (!v) HRETURN(TRUE); - while (n--) { - if (*v++) HRETURN(FALSE); - } - FUNC_LEAVE(TRUE); + if (!v) + HGOTO_DONE(TRUE); + while (n--) + if (*v++) + HGOTO_DONE(FALSE); + +done: + FUNC_LEAVE(ret_value); } /*------------------------------------------------------------------------- @@ -158,14 +165,19 @@ H5V_vector_zerop_u(int n, const hsize_t *v) static H5_inline htri_t UNUSED H5V_vector_zerop_s(int n, const hssize_t *v) { + htri_t ret_value=TRUE; /* Return value */ + /* Use FUNC_ENTER_NOINIT here to avoid performance issues */ FUNC_ENTER_NOINIT(H5V_vector_zerop_s); - if (!v) HRETURN(TRUE); - while (n--) { - if (*v++) HRETURN(FALSE); - } - FUNC_LEAVE(TRUE); + if (!v) + HGOTO_DONE(TRUE); + while (n--) + if (*v++) + HGOTO_DONE(FALSE); + +done: + FUNC_LEAVE(ret_value); } /*------------------------------------------------------------------------- @@ -190,17 +202,21 @@ H5V_vector_zerop_s(int n, const hssize_t *v) static H5_inline int UNUSED H5V_vector_cmp_u (int n, const hsize_t *v1, const hsize_t *v2) { + int ret_value=0; /* Return value */ + /* Use FUNC_ENTER_NOINIT here to avoid performance issues */ FUNC_ENTER_NOINIT(H5V_vector_cmp_u); - if (v1 == v2) HRETURN(0); + if (v1 == v2) HGOTO_DONE(0); while (n--) { - if ((v1 ? *v1 : 0) < (v2 ? *v2 : 0)) HRETURN(-1); - if ((v1 ? *v1 : 0) > (v2 ? *v2 : 0)) HRETURN(1); + if ((v1 ? *v1 : 0) < (v2 ? *v2 : 0)) HGOTO_DONE(-1); + if ((v1 ? *v1 : 0) > (v2 ? *v2 : 0)) HGOTO_DONE(1); if (v1) v1++; if (v2) v2++; } - FUNC_LEAVE(0); + +done: + FUNC_LEAVE(ret_value); } @@ -226,17 +242,21 @@ H5V_vector_cmp_u (int n, const hsize_t *v1, const hsize_t *v2) static H5_inline int UNUSED H5V_vector_cmp_s (unsigned n, const hssize_t *v1, const hssize_t *v2) { + int ret_value=0; /* Return value */ + /* Use FUNC_ENTER_NOINIT here to avoid performance issues */ FUNC_ENTER_NOINIT(H5V_vector_cmp_s); - if (v1 == v2) HRETURN(0); + if (v1 == v2) HGOTO_DONE(0); while (n--) { - if ((v1 ? *v1 : 0) < (v2 ? *v2 : 0)) HRETURN(-1); - if ((v1 ? *v1 : 0) > (v2 ? *v2 : 0)) HRETURN(1); + if ((v1 ? *v1 : 0) < (v2 ? *v2 : 0)) HGOTO_DONE(-1); + if ((v1 ? *v1 : 0) > (v2 ? *v2 : 0)) HGOTO_DONE(1); if (v1) v1++; if (v2) v2++; } - FUNC_LEAVE(0); + +done: + FUNC_LEAVE(ret_value); } |