summaryrefslogtreecommitdiffstats
path: root/src/H5TB.c
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2004-11-18 20:11:50 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2004-11-18 20:11:50 (GMT)
commit6ec311b1d32001ec035902ca2c8420ecc216e14d (patch)
tree6b34e12044d5a51642ed1e1a7824790ef772c5c2 /src/H5TB.c
parent8c97a51f70c7fb3ddbc50aa32f76750a4da54037 (diff)
downloadhdf5-6ec311b1d32001ec035902ca2c8420ecc216e14d.zip
hdf5-6ec311b1d32001ec035902ca2c8420ecc216e14d.tar.gz
hdf5-6ec311b1d32001ec035902ca2c8420ecc216e14d.tar.bz2
[svn-r9550] Purpose:
Code optimization Description: Rework & move around some of the macros for querying balanced properties of nodes to speed up tree balancing code. Platforms tested: FreeBSD 4.10 (sleipnir) w/parallel Solaris 2.7 (arabica) Too minor to require h5committest
Diffstat (limited to 'src/H5TB.c')
-rw-r--r--src/H5TB.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/src/H5TB.c b/src/H5TB.c
index db140c7..7e6f946 100644
--- a/src/H5TB.c
+++ b/src/H5TB.c
@@ -1575,15 +1575,17 @@ H5TB_swapkid(H5TB_NODE ** root, H5TB_NODE * ptr, int side)
static herr_t
H5TB_balance(H5TB_NODE ** root, H5TB_NODE * ptr, int side, int added)
{
+ H5TB_leaf olcnt, orcnt; /* Old left & right counts for node */
+ H5TB_flag odouble; /* Old 'double' status */
int deeper = added; /* 1 if sub-tree got longer; -1 if got shorter */
int odelta;
- int obal;
FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5TB_balance);
while (NULL != ptr) {
- odelta = Delta(ptr, side); /* delta before the node was added */
- obal = UnBal(ptr);
+ olcnt = LeftCnt(ptr);
+ orcnt = RightCnt(ptr);
+ odouble = Double(ptr);
if (LEFT == side) /* One more/fewer left child: */
if (0 < added)
ptr->lcnt++; /* LeftCnt(ptr)++ */
@@ -1595,6 +1597,7 @@ H5TB_balance(H5TB_NODE ** root, H5TB_NODE * ptr, int side, int added)
ptr->rcnt--; /* RightCnt(ptr)-- */
if (0 != deeper)
{ /* One leg got longer or shorter: */
+ odelta = DeltaCnt(olcnt, orcnt, odouble, side); /* compute delta before the node was added */
if ((deeper < 0 && odelta < 0) || (deeper > 0 && odelta > 0))
{ /* Became too unbalanced: */
H5TB_NODE *kid;
@@ -1623,7 +1626,7 @@ H5TB_balance(H5TB_NODE ** root, H5TB_NODE * ptr, int side, int added)
ptr = H5TB_swapkid(root, ptr, side);
}
}
- else if (obal)
+ else if (olcnt!=orcnt)
{ /* Just became balanced: */
ptr->flags &= ~H5TB_UNBAL;
if (0 < deeper)