[llvm-branch-commits] [libcxx] [libc++] Add accessor functions to __tree_node_base (PR #147679)

Louis Dionne via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Wed Sep 24 07:55:26 PDT 2025


================
@@ -132,18 +139,18 @@ unsigned __tree_sub_invariant(_NodePtr __x) {
   if (__x->__left_ == __x->__right_ && __x->__left_ != nullptr)
     return 0;
   // If this is red, neither child can be red
-  if (!__x->__is_black_) {
-    if (__x->__left_ && !__x->__left_->__is_black_)
+  if (__x->__color_ == __red) {
----------------
ldionne wrote:

```suggestion
  if (__x->__color_ == __tree_color::__red) {
```

The combination of `using enum __tree_color;` and using lowercase for the enum constants hurt readability IMO -- it makes it look like a variable comparison. I would at minimum qualify the enum accesses throughout.

https://github.com/llvm/llvm-project/pull/147679


More information about the llvm-branch-commits mailing list