[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: [Xen-devel] [Resend][PATCH 13/17] rbtree: add __rb_change_child() helper function
On Thu, 2017-06-01 at 02:50 +0530, Praveen Kumar wrote: > @@ -65,6 +65,22 @@ static inline struct rb_node *rb_red_parent(struct > rb_node *red) > return (struct rb_node *)red->__rb_parent_color; > } > > +static inline void > +__rb_change_child(struct rb_node *old, struct rb_node *new, > + struct rb_node *parent, struct rb_root *root) > +{ > + if (parent) > + { > + if (parent->rb_left == old) > + parent->rb_left = new; > + else > + parent->rb_right = new; > + } else > + root->rb_node = new; > +} > + > + > + > why all these blank lines? They're not there in the original Linux commit, AFAICT. > /* > * Helper function for rotations: > * - old's parent and color get assigned to ne > > @@ -418,15 +421,8 @@ void rb_erase(struct rb_node *node, struct > rb_root *root) > > if (child) > rb_set_parent(child, parent); > - if (parent) > - { > - if (parent->rb_left == node) > - parent->rb_left = child; > - else > - parent->rb_right = child; > - } > - else > - root->rb_node = child; > + > Same for this one here. > + __rb_change_child(node, child, parent, root); > > color: > if (color == RB_BLACK) > @@ -523,14 +519,8 @@ void rb_replace_node(struct rb_node *victim, > struct rb_node *new, > struct rb_node *parent = rb_parent(victim); > > /* Set the surrounding nodes to point to the replacement */ > - if (parent) { > - if (victim == parent->rb_left) > - parent->rb_left = new; > - else > - parent->rb_right = new; > - } else { > - root->rb_node = new; > - } > + __rb_change_child(victim, new, parent, root); > + > And here too. Regards, Dario -- <<This happens because I choose it to happen!>> (Raistlin Majere) ----------------------------------------------------------------- Dario Faggioli, Ph.D, http://about.me/dario.faggioli Senior Software Engineer, Citrix Systems R&D Ltd., Cambridge (UK) Attachment:
signature.asc _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxx https://lists.xen.org/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |