From 9a86915b40647b5586efc560019fd7ad466cc7d5 Mon Sep 17 00:00:00 2001 From: Timo Kreuzer Date: Tue, 27 Mar 2012 21:41:39 +0000 Subject: [PATCH] [RTL] Remove pointless ASSERTs, instead set the balance of the new node to balanced, before inserting it. Dedicated to Alex. svn path=/trunk/; revision=56253 --- reactos/lib/rtl/avlsupp.c | 58 +-------------------------------------- 1 file changed, 1 insertion(+), 57 deletions(-) diff --git a/reactos/lib/rtl/avlsupp.c b/reactos/lib/rtl/avlsupp.c index f64e107bbda..3360418426c 100644 --- a/reactos/lib/rtl/avlsupp.c +++ b/reactos/lib/rtl/avlsupp.c @@ -203,45 +203,6 @@ RtlpRebalanceAvlTreeNode(IN PRTL_BALANCED_LINKS Node) return TRUE; } -#ifdef PRTL_BALANCED_LINKS -void -Indent(ULONG Level) -{ - while (Level--) - { - DbgPrint(" "); - } -} - -VOID -DbgDumpAvlNodes( - PRTL_BALANCED_LINKS Node, - ULONG Level) -{ - if (Level == 0) - { - DbgPrint("++++++++++++++++++++++++++++++++++++++++++++++++++++++\n"); - DbgPrint("Root = %p\n", Node); - } - - Indent(Level+1); DbgPrint("LetChid = %p", Node->LeftChild); - if (Node->LeftChild) - { - DbgPrint("(%lx, %lx)\n", Node->LeftChild->StartingVpn,Node->LeftChild->EndingVpn); - DbgDumpAvlNodes(Node->LeftChild, Level+1); - } - else DbgPrint("\n"); - Indent(Level+1); DbgPrint("RightChild = %p\n", Node->RightChild); - if (Node->RightChild) - { - DbgPrint("(%lx, %lx)\n", Node->RightChild->StartingVpn,Node->RightChild->EndingVpn); - DbgDumpAvlNodes(Node->RightChild, Level+1); - } - else DbgPrint("\n"); -} -#endif - - VOID FORCEINLINE RtlpInsertAvlTreeNode(IN PRTL_AVL_TABLE Table, @@ -254,6 +215,7 @@ RtlpInsertAvlTreeNode(IN PRTL_AVL_TABLE Table, /* Initialize the new inserted element */ MI_ASSERT(SearchResult != TableFoundNode); NewNode->LeftChild = NewNode->RightChild = NULL; + RtlSetBalance(NewNode, RtlBalancedAvlTree); /* Increase element count */ Table->NumberGenericTableElements++; @@ -263,15 +225,6 @@ RtlpInsertAvlTreeNode(IN PRTL_AVL_TABLE Table, { /* This is the new root node */ RtlInsertAsRightChildAvl(&Table->BalancedRoot, NewNode); - //MI_ASSERT(RtlBalance(NewNode) == RtlBalancedAvlTree); - if (RtlBalance(NewNode) != RtlBalancedAvlTree) - { - DPRINT1("Warning: Root node unbalanced?\n"); -#ifdef PRTL_BALANCED_LINKS - DbgDumpAvlNodes(&Table->BalancedRoot, 0); - KeRosDumpStackFrames(NULL, 0); -#endif - } /* On AVL trees, we also update the depth */ ASSERT(Table->DepthOfTree == 0); @@ -290,15 +243,6 @@ RtlpInsertAvlTreeNode(IN PRTL_AVL_TABLE Table, } /* Little cheat to save on loop processing, taken from Timo */ - //MI_ASSERT(RtlBalance(NewNode) == RtlBalancedAvlTree); - if (RtlBalance(NewNode) != RtlBalancedAvlTree) - { - DPRINT1("Warning: Root node unbalanced?\n"); -#ifdef PRTL_BALANCED_LINKS - DbgDumpAvlNodes(&Table->BalancedRoot, 0); - KeRosDumpStackFrames(NULL, 0); -#endif - } RtlSetBalance(&Table->BalancedRoot, RtlLeftHeavyAvlTree); /*