From a58adc04a7368f65b7822b8c0811ebaad8243ee5 Mon Sep 17 00:00:00 2001 From: Quincey Koziol Date: Fri, 30 Apr 2004 09:11:43 -0500 Subject: [svn-r8436] Purpose: Code optimization Description: Hoist some if statements out of a loop in vector comparision routines that are called very frequently by chunking code. Platforms tested: Solaris 2.7 (arabica) FreeBSD 4.9 (sleipnir) too minor to require h5committest --- src/H5Vprivate.h | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/src/H5Vprivate.h b/src/H5Vprivate.h index f109e27..e56ddf0 100644 --- a/src/H5Vprivate.h +++ b/src/H5Vprivate.h @@ -231,11 +231,13 @@ H5V_vector_cmp_u (int n, const hsize_t *v1, const hsize_t *v2) FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5V_vector_cmp_u); if (v1 == v2) HGOTO_DONE(0); + if (v1 == NULL) HGOTO_DONE(-1) + if (v2 == NULL) HGOTO_DONE(1) while (n--) { - 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++; + if (*v1 < *v2) HGOTO_DONE(-1) + if (*v1 > *v2) HGOTO_DONE(1) + v1++; + v2++; } done: @@ -271,11 +273,13 @@ H5V_vector_cmp_s (unsigned n, const hssize_t *v1, const hssize_t *v2) FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5V_vector_cmp_s); if (v1 == v2) HGOTO_DONE(0); + if (v1 == NULL) HGOTO_DONE(-1) + if (v2 == NULL) HGOTO_DONE(1) while (n--) { - 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++; + if (*v1 < *v2) HGOTO_DONE(-1) + if (*v1 > *v2) HGOTO_DONE(1) + v1++; + v2++; } done: -- cgit v0.12