summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2004-05-13 21:02:37 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2004-05-13 21:02:37 (GMT)
commita4c58cf6411c223af69d40c18c28d8e755c5d45e (patch)
tree9571ebe1230285a77b5b75112671e444c3827f88
parenta3fd0e95a7c179efb956fe1b36ab1af128fe323e (diff)
downloadhdf5-a4c58cf6411c223af69d40c18c28d8e755c5d45e.zip
hdf5-a4c58cf6411c223af69d40c18c28d8e755c5d45e.tar.gz
hdf5-a4c58cf6411c223af69d40c18c28d8e755c5d45e.tar.bz2
[svn-r8515] Purpose:
Code optimization Description: Eliminate some trivial functions with macros that perform the same operation. Platforms tested: Solaris 2.7 (arabica) FreeBSD 4.9 (sleipnir) w/parallel
-rw-r--r--src/H5TB.c146
-rw-r--r--src/H5TBprivate.h12
2 files changed, 10 insertions, 148 deletions
diff --git a/src/H5TB.c b/src/H5TB.c
index 00eadc1..98ded27 100644
--- a/src/H5TB.c
+++ b/src/H5TB.c
@@ -80,8 +80,6 @@
* ITM **H5TB_dins( ITM ***tree, ITM *item, void *key );
* ITM **H5TB_ins( ITM ***root, ITM *item, void *key, int (*cmp)(), int arg );
* ITM *H5TB_rem( ITM ***root, ITM **node, void **kp );
- * ITM **H5TB_first( ITM **root ), **H5TB_last( ITM **root );
- * ITM **H5TB_next( ITM **node ), **H5TB_prev( ITM **node );
* ITM ***H5TB_dfree( ITM ***tree, void (*df)(ITM *), void (*kf)(void *) );
* void H5TB_free( ITM ***root, void (*df)(ITM *), void (*kf)(void *) );
*/
@@ -102,12 +100,10 @@
#define Max(a,b) ( (a) > (b) ? (a) : (b) )
/* Local Function Prototypes */
-static H5TB_NODE * H5TB_end(H5TB_NODE * root, int side);
static H5TB_NODE *H5TB_ffind(H5TB_NODE * root, const void * key, unsigned fast_compare,
H5TB_NODE ** pp);
static herr_t H5TB_balance(H5TB_NODE ** root, H5TB_NODE * ptr, int side, int added);
static H5TB_NODE *H5TB_swapkid(H5TB_NODE ** root, H5TB_NODE * ptr, int side);
-static H5TB_NODE *H5TB_nbr(H5TB_NODE * ptr, int side);
#ifdef H5TB_DEBUG
static herr_t H5TB_printNode(H5TB_NODE * node, void(*key_dump)(void *,void *));
@@ -978,144 +974,6 @@ done:
/*-------------------------------------------------------------------------
- * Function: H5TB_first
- *
- * Purpose: Retrieves a pointer to node from the tree with the lowest(first)
- * key value. If the tree is empy NULL is returned. Examples:
- * node= H5TB_first(*tree);
- * node= H5TB_first(root);
- *
- * Return: Success: Pointer to a valid H5TB node
- * Failure: NULL
- *
- * Programmer: Quincey Koziol
- * Friday, May 6, 2000
- *
- * Modifications:
- *
- * Notes:
- *
- *-------------------------------------------------------------------------
- */
-H5TB_NODE *
-H5TB_first(H5TB_NODE * root)
-{
- H5TB_NODE *ret_value; /* Return value */
-
- FUNC_ENTER_NOAPI(H5TB_first,NULL);
-
- /* Set return value */
- ret_value=H5TB_end(root, LEFT);
-
-done:
- FUNC_LEAVE_NOAPI(ret_value);
-} /* end H5TB_first() */
-
-
-/*-------------------------------------------------------------------------
- * Function: H5TB_last
- *
- * Purpose: Retrieves a pointer to node from the tree with the highest(last)
- * key value. If the tree is empy NULL is returned. Examples:
- * node= H5TB_last(tree->root);
- * node= H5TB_last(node); (* Last node in a sub-tree *)
- *
- * Return: Success: Pointer to a valid H5TB node
- * Failure: NULL
- *
- * Programmer: Quincey Koziol
- * Friday, May 6, 2000
- *
- * Modifications:
- *
- * Notes:
- *
- *-------------------------------------------------------------------------
- */
-H5TB_NODE *
-H5TB_last(H5TB_NODE * root)
-{
- H5TB_NODE *ret_value; /* Return value */
-
- FUNC_ENTER_NOAPI(H5TB_last,NULL);
-
- /* Set return value */
- ret_value=H5TB_end(root, RIGHT);
-
-done:
- FUNC_LEAVE_NOAPI(ret_value);
-} /* end H5TB_last() */
-
-
-/*-------------------------------------------------------------------------
- * Function: H5TB_next
- *
- * Purpose: Returns a pointer the node from the tree with the next highest
- * key value relative to the node pointed to by `node'. If `node' points the
- * last node of the tree, NULL is returned.
- *
- * Return: Success: Pointer to a valid H5TB node
- * Failure: NULL
- *
- * Programmer: Quincey Koziol
- * Friday, May 6, 2000
- *
- * Modifications:
- *
- * Notes:
- *
- *-------------------------------------------------------------------------
- */
-H5TB_NODE *
-H5TB_next(H5TB_NODE * node)
-{
- H5TB_NODE *ret_value; /* Return value */
-
- FUNC_ENTER_NOAPI(H5TB_next,NULL);
-
- /* Set return value */
- ret_value=H5TB_nbr(node, RIGHT);
-
-done:
- FUNC_LEAVE_NOAPI(ret_value);
-} /* end H5TB_next() */
-
-
-/*-------------------------------------------------------------------------
- * Function: H5TB_prev
- *
- * Purpose: Returns a pointer the node from the tree with the previous lowest
- * key value relative to the node pointed to by `node'. If `node' points the
- * first node of the tree, NULL is returned.
- *
- * Return: Success: Pointer to a valid H5TB node
- * Failure: NULL
- *
- * Programmer: Quincey Koziol
- * Friday, May 6, 2000
- *
- * Modifications:
- *
- * Notes:
- *
- *-------------------------------------------------------------------------
- */
-H5TB_NODE *
-H5TB_prev(H5TB_NODE * node)
-{
- H5TB_NODE *ret_value; /* Return value */
-
- FUNC_ENTER_NOAPI(H5TB_prev,NULL);
-
- /* Set return value */
- ret_value=H5TB_nbr(node, LEFT);
-
-done:
- FUNC_LEAVE_NOAPI(ret_value);
-} /* end H5TB_prev() */
-
-
-/*-------------------------------------------------------------------------
* Function: H5TB_dfree
*
* Purpose: Frees up an entire tree. `fd' is a pointer to a function that
@@ -1420,7 +1278,7 @@ done:
*
*-------------------------------------------------------------------------
*/
-static H5TB_NODE *
+H5TB_NODE *
H5TB_end(H5TB_NODE * root, int side)
{
FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5TB_end);
@@ -1435,7 +1293,7 @@ H5TB_end(H5TB_NODE * root, int side)
} /* end H5TB_end() */
/* Returns pointer to neighboring node (to LEFT or RIGHT): */
-static H5TB_NODE *
+H5TB_NODE *
H5TB_nbr(H5TB_NODE * ptr, int side)
{
H5TB_NODE *ret_value; /* Return value */
diff --git a/src/H5TBprivate.h b/src/H5TBprivate.h
index 25d46ea..f66d87c 100644
--- a/src/H5TBprivate.h
+++ b/src/H5TBprivate.h
@@ -105,6 +105,12 @@ typedef struct H5TB_tree
/* Define an access macro for getting a node's data */
#define H5TB_NODE_DATA(n) ((n)->data)
+/* Define some "function-like" macros */
+#define H5TB_first(root) H5TB_end(root,LEFT)
+#define H5TB_last(root) H5TB_end(root,RIGHT)
+#define H5TB_next(node) H5TB_nbr(node,RIGHT)
+#define H5TB_prev(node) H5TB_nbr(node,LEFT)
+
#if defined c_plusplus || defined __cplusplus
extern "C"
{
@@ -122,13 +128,11 @@ H5_DLL H5TB_NODE *H5TB_index (H5TB_NODE * root, unsigned indx);
H5_DLL H5TB_NODE *H5TB_dins (H5TB_TREE * tree, void * item, void * key);
H5_DLL H5TB_NODE *H5TB_ins (H5TB_NODE ** root, void * item, void * key, H5TB_cmp_t cmp, int arg);
H5_DLL void *H5TB_rem(H5TB_NODE ** root, H5TB_NODE * node, void * *kp);
-H5_DLL H5TB_NODE *H5TB_first (H5TB_NODE * root);
-H5_DLL H5TB_NODE *H5TB_last (H5TB_NODE * root);
-H5_DLL H5TB_NODE *H5TB_next (H5TB_NODE * node);
-H5_DLL H5TB_NODE *H5TB_prev (H5TB_NODE * node);
H5_DLL H5TB_TREE *H5TB_dfree (H5TB_TREE * tree, void(*fd) (void *), void(*fk) (void *));
H5_DLL void *H5TB_free (H5TB_NODE ** root, void(*fd) (void *), void(*fk) (void *));
H5_DLL long H5TB_count (H5TB_TREE * tree);
+H5_DLL H5TB_NODE * H5TB_end(H5TB_NODE * root, int side);
+H5_DLL H5TB_NODE *H5TB_nbr(H5TB_NODE * ptr, int side);
#ifdef H5TB_DEBUG
H5_DLL herr_t H5TB_dump(H5TB_TREE *ptree, void (*key_dump)(void *,void *), int method);