From 243e20669c70482051ec7da7d14a568132756b7c Mon Sep 17 00:00:00 2001 From: Quincey Koziol Date: Fri, 30 Apr 2004 09:13:05 -0500 Subject: [svn-r8437] 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 1247912..3ed0707 100644 --- a/src/H5Vprivate.h +++ b/src/H5Vprivate.h @@ -221,11 +221,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: @@ -261,11 +263,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