Remove from RB_REMOVE_COLOR some null checks
where the pointer checked is provably never null. Restructure the surrounding code just enough to make the non-nullness obvious. Reviewed by: markj Tested by: pho Differential Revision: https://reviews.freebsd.org/D25089
This commit is contained in:
parent
640a96a231
commit
123df813ee
|
@ -493,26 +493,23 @@ name##_RB_REMOVE_COLOR(struct name *head, struct type *parent) \
|
||||||
RB_ROTATE_LEFT(head, parent, tmp, field);\
|
RB_ROTATE_LEFT(head, parent, tmp, field);\
|
||||||
tmp = RB_RIGHT(parent, field); \
|
tmp = RB_RIGHT(parent, field); \
|
||||||
} \
|
} \
|
||||||
if (!RB_ISRED(RB_LEFT(tmp, field), field) && \
|
if (RB_ISRED(RB_LEFT(tmp, field), field)) { \
|
||||||
!RB_ISRED(RB_RIGHT(tmp, field), field)) { \
|
struct type *oleft; \
|
||||||
|
oleft = RB_LEFT(tmp, field); \
|
||||||
|
RB_COLOR(oleft, field) = RB_BLACK; \
|
||||||
|
RB_COLOR(tmp, field) = RB_RED; \
|
||||||
|
RB_ROTATE_RIGHT(head, tmp, oleft, field); \
|
||||||
|
tmp = RB_RIGHT(parent, field); \
|
||||||
|
} else if (!RB_ISRED(RB_RIGHT(tmp, field), field)) { \
|
||||||
RB_COLOR(tmp, field) = RB_RED; \
|
RB_COLOR(tmp, field) = RB_RED; \
|
||||||
elm = parent; \
|
elm = parent; \
|
||||||
parent = RB_PARENT(elm, field); \
|
parent = RB_PARENT(elm, field); \
|
||||||
continue; \
|
continue; \
|
||||||
} \
|
} \
|
||||||
if (!RB_ISRED(RB_RIGHT(tmp, field), field)) { \
|
if (RB_ISRED(RB_RIGHT(tmp, field), field)) \
|
||||||
struct type *oleft; \
|
RB_COLOR(RB_RIGHT(tmp, field), field) = RB_BLACK; \
|
||||||
if ((oleft = RB_LEFT(tmp, field)) \
|
|
||||||
!= NULL) \
|
|
||||||
RB_COLOR(oleft, field) = RB_BLACK; \
|
|
||||||
RB_COLOR(tmp, field) = RB_RED; \
|
|
||||||
RB_ROTATE_RIGHT(head, tmp, oleft, field); \
|
|
||||||
tmp = RB_RIGHT(parent, field); \
|
|
||||||
} \
|
|
||||||
RB_COLOR(tmp, field) = RB_COLOR(parent, field); \
|
RB_COLOR(tmp, field) = RB_COLOR(parent, field); \
|
||||||
RB_COLOR(parent, field) = RB_BLACK; \
|
RB_COLOR(parent, field) = RB_BLACK; \
|
||||||
if (RB_RIGHT(tmp, field)) \
|
|
||||||
RB_COLOR(RB_RIGHT(tmp, field), field) = RB_BLACK; \
|
|
||||||
RB_ROTATE_LEFT(head, parent, tmp, field); \
|
RB_ROTATE_LEFT(head, parent, tmp, field); \
|
||||||
elm = RB_ROOT(head); \
|
elm = RB_ROOT(head); \
|
||||||
break; \
|
break; \
|
||||||
|
@ -523,26 +520,23 @@ name##_RB_REMOVE_COLOR(struct name *head, struct type *parent) \
|
||||||
RB_ROTATE_RIGHT(head, parent, tmp, field);\
|
RB_ROTATE_RIGHT(head, parent, tmp, field);\
|
||||||
tmp = RB_LEFT(parent, field); \
|
tmp = RB_LEFT(parent, field); \
|
||||||
} \
|
} \
|
||||||
if (!RB_ISRED(RB_LEFT(tmp, field), field) && \
|
if (RB_ISRED(RB_RIGHT(tmp, field), field)) { \
|
||||||
!RB_ISRED(RB_RIGHT(tmp, field), field)) { \
|
struct type *oright; \
|
||||||
|
oright = RB_RIGHT(tmp, field); \
|
||||||
|
RB_COLOR(oright, field) = RB_BLACK; \
|
||||||
|
RB_COLOR(tmp, field) = RB_RED; \
|
||||||
|
RB_ROTATE_LEFT(head, tmp, oright, field); \
|
||||||
|
tmp = RB_LEFT(parent, field); \
|
||||||
|
} else if (!RB_ISRED(RB_LEFT(tmp, field), field)) { \
|
||||||
RB_COLOR(tmp, field) = RB_RED; \
|
RB_COLOR(tmp, field) = RB_RED; \
|
||||||
elm = parent; \
|
elm = parent; \
|
||||||
parent = RB_PARENT(elm, field); \
|
parent = RB_PARENT(elm, field); \
|
||||||
continue; \
|
continue; \
|
||||||
} \
|
} \
|
||||||
if (!RB_ISRED(RB_LEFT(tmp, field), field)) { \
|
if (RB_ISRED(RB_LEFT(tmp, field), field)) \
|
||||||
struct type *oright; \
|
RB_COLOR(RB_LEFT(tmp, field), field) = RB_BLACK; \
|
||||||
if ((oright = RB_RIGHT(tmp, field)) \
|
|
||||||
!= NULL) \
|
|
||||||
RB_COLOR(oright, field) = RB_BLACK; \
|
|
||||||
RB_COLOR(tmp, field) = RB_RED; \
|
|
||||||
RB_ROTATE_LEFT(head, tmp, oright, field); \
|
|
||||||
tmp = RB_LEFT(parent, field); \
|
|
||||||
} \
|
|
||||||
RB_COLOR(tmp, field) = RB_COLOR(parent, field); \
|
RB_COLOR(tmp, field) = RB_COLOR(parent, field); \
|
||||||
RB_COLOR(parent, field) = RB_BLACK; \
|
RB_COLOR(parent, field) = RB_BLACK; \
|
||||||
if (RB_LEFT(tmp, field)) \
|
|
||||||
RB_COLOR(RB_LEFT(tmp, field), field) = RB_BLACK; \
|
|
||||||
RB_ROTATE_RIGHT(head, parent, tmp, field); \
|
RB_ROTATE_RIGHT(head, parent, tmp, field); \
|
||||||
elm = RB_ROOT(head); \
|
elm = RB_ROOT(head); \
|
||||||
break; \
|
break; \
|
||||||
|
|
Loading…
Reference in New Issue