diff options
author | Quincey Koziol <koziol@hdfgroup.org> | 2003-05-17 21:40:47 (GMT) |
---|---|---|
committer | Quincey Koziol <koziol@hdfgroup.org> | 2003-05-17 21:40:47 (GMT) |
commit | dddf167923a28c9cf65b05da565e1b7197b0cd37 (patch) | |
tree | 22baff78511c4926a372d57f4526d497d53a3057 | |
parent | 9aba174ba53c80e150ea5d3a40d46bfd14185554 (diff) | |
download | hdf5-dddf167923a28c9cf65b05da565e1b7197b0cd37.zip hdf5-dddf167923a28c9cf65b05da565e1b7197b0cd37.tar.gz hdf5-dddf167923a28c9cf65b05da565e1b7197b0cd37.tar.bz2 |
[svn-r6890] Purpose:
New feature
Description:
Added "fast comparison" code for hsize_t's, since they are used in th
raw data chunking I/O code now.
Platforms tested:
h5committested
-rw-r--r-- | src/H5TB.c | 48 | ||||
-rw-r--r-- | src/H5TBprivate.h | 1 |
2 files changed, 49 insertions, 0 deletions
@@ -192,6 +192,32 @@ H5TB_int_cmp(const void *k1, const void *k2, int UNUSED cmparg) /*------------------------------------------------------------------------- + * Function: H5TB_hsize_cmp + * + * Purpose: Key comparison routine for TBBT routines + * + * Return: same as comparing two hsize_t's + * + * Programmer: Quincey Koziol + * Friday, December 20, 2002 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +static int +H5TB_hsize_cmp(const void *k1, const void *k2, int UNUSED cmparg) +{ + FUNC_ENTER_NOINIT(H5TB_hsize_cmp); + + assert(k1); + assert(k2); + + FUNC_LEAVE_NOAPI(*(const hsize_t *)k1 - *(const hsize_t *)k2); +} /* end H5TB_hsize_cmp() */ + + +/*------------------------------------------------------------------------- * Function: H5TB_fast_dmake * * Purpose: Wrapper around H5TB_dmake for callers which want to use @@ -233,6 +259,11 @@ H5TB_fast_dmake(unsigned fast_compare) cmparg=-1; break; + case H5TB_FAST_HSIZE_COMPARE: + compar=H5TB_hsize_cmp; + cmparg=-1; + break; + default: HGOTO_ERROR (H5E_TBBT, H5E_BADVALUE, NULL, "invalid fast comparison type"); } /* end switch */ @@ -1459,6 +1490,23 @@ H5TB_ffind(H5TB_NODE * root, const void * key, unsigned fast_compare, H5TB_NODE ret_value= (0 == cmp) ? ptr : NULL; break; + case H5TB_FAST_HSIZE_COMPARE: + if (ptr) { + while (0 != (cmp = (int)(*(const hsize_t *)key - *(hsize_t *)ptr->key))) { + parent = ptr; + side = (cmp < 0) ? LEFT : RIGHT; + if (!HasChild(ptr, side)) + break; + ptr = ptr->link[side]; + } /* end while */ + } /* end if */ + if (NULL != pp) + *pp = parent; + + /* Set return value */ + ret_value= (0 == cmp) ? ptr : NULL; + break; + default: break; } /* end switch */ diff --git a/src/H5TBprivate.h b/src/H5TBprivate.h index 665f3eb..25d46ea 100644 --- a/src/H5TBprivate.h +++ b/src/H5TBprivate.h @@ -100,6 +100,7 @@ typedef struct H5TB_tree #define H5TB_FAST_HADDR_COMPARE 1 #define H5TB_FAST_INTN_COMPARE 2 #define H5TB_FAST_STR_COMPARE 3 +#define H5TB_FAST_HSIZE_COMPARE 4 /* Define an access macro for getting a node's data */ #define H5TB_NODE_DATA(n) ((n)->data) |