Page MenuHomeFreeBSD

D36317.diff
No OneTemporary

D36317.diff

diff --git a/sys/sys/tree.h b/sys/sys/tree.h
--- a/sys/sys/tree.h
+++ b/sys/sys/tree.h
@@ -728,26 +728,21 @@
name##_RB_INSERT(struct name *head, struct type *elm) \
{ \
struct type *tmp; \
+ struct type **tmpp = &RB_ROOT(head); \
struct type *parent = NULL; \
- __typeof(cmp(NULL, NULL)) comp = 0; \
- tmp = RB_ROOT(head); \
- while (tmp) { \
+ \
+ while ((tmp = *tmpp) != NULL) { \
parent = tmp; \
- comp = (cmp)(elm, parent); \
+ __typeof(cmp(NULL, NULL)) comp = (cmp)(elm, parent); \
if (comp < 0) \
- tmp = RB_LEFT(tmp, field); \
+ tmpp = &RB_LEFT(parent, field); \
else if (comp > 0) \
- tmp = RB_RIGHT(tmp, field); \
+ tmpp = &RB_RIGHT(parent, field); \
else \
- return (tmp); \
+ return (parent); \
} \
RB_SET(elm, parent, field); \
- if (parent == NULL) \
- RB_ROOT(head) = elm; \
- else if (comp < 0) \
- RB_LEFT(parent, field) = elm; \
- else \
- RB_RIGHT(parent, field) = elm; \
+ *tmpp = elm; \
name##_RB_INSERT_COLOR(head, elm); \
RB_UPDATE_AUGMENT(elm, field); \
return (NULL); \

File Metadata

Mime Type
text/plain
Expires
Fri, Jan 17, 12:05 PM (19 h, 46 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
15838477
Default Alt Text
D36317.diff (1 KB)

Event Timeline