mirror of
https://github.com/HDFGroup/hdf5.git
synced 2024-11-27 02:10:55 +08:00
[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
This commit is contained in:
parent
9aba174ba5
commit
dddf167923
48
src/H5TB.c
48
src/H5TB.c
@ -190,6 +190,32 @@ H5TB_int_cmp(const void *k1, const void *k2, int UNUSED cmparg)
|
||||
FUNC_LEAVE_NOAPI(*(const int *)k1 - *(const int *)k2);
|
||||
} /* end H5TB_int_cmp() */
|
||||
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* 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
|
||||
@ -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 */
|
||||
|
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user