Skip to content

Faster RB tree violation checks - #69

Open
odorovskoy wants to merge 1 commit into
5cript:masterfrom
odorovskoy:violation-check-speedup
Open

Faster RB tree violation checks#69
odorovskoy wants to merge 1 commit into
5cript:masterfrom
odorovskoy:violation-check-speedup

Conversation

@odorovskoy

Copy link
Copy Markdown
Contributor

testRedBlackPropertyViolation() optimizations described in #68

@5cript

5cript commented Aug 30, 2026

Copy link
Copy Markdown
Owner

Probably overkill for a test tool, but thank you for the contribution. I will review this soon when I have time again.

@5cript 5cript left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@odorovskoy This is an enormous improvement.
Can you do the 2 mini improvements? I'll then approve and merge.

Comment thread tests/test_utility.hpp
auto nodeColor = i.color();
if (nodeColor == rb_color::red)
// check that all nodes have red or black coloring. (seems obvious, but is not on bug)
EXPECT_EQ(true, node.color() == rb_color::black || node.color() == rb_color::red);

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I prefer EXPECT_TRUE, i know the old impl also used EXPECT_EQ.

Comment thread tests/test_utility.hpp
@@ -19,82 +18,34 @@ void testRedBlackPropertyViolation(TreeT const& tree)
// root is always black.
EXPECT_EQ(tree.root().color(), rb_color::black);

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You didnt introduce this, but this is unchecked root access that could blow up on an empty tree.
Can you fix this to for me?

It could be relevant now when this function is used more frequently.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants