diff --git a/components/gfx/display_list/mod.rs b/components/gfx/display_list/mod.rs index 9dacfd41b72..2b5b8707780 100644 --- a/components/gfx/display_list/mod.rs +++ b/components/gfx/display_list/mod.rs @@ -109,14 +109,12 @@ impl DisplayList { /// `other` in the process. #[inline] pub fn append_from(&mut self, other: &mut DisplayList) { - servo_dlist::append_from(&mut self.background_and_borders, - &mut other.background_and_borders); - servo_dlist::append_from(&mut self.block_backgrounds_and_borders, - &mut other.block_backgrounds_and_borders); - servo_dlist::append_from(&mut self.floats, &mut other.floats); - servo_dlist::append_from(&mut self.content, &mut other.content); - servo_dlist::append_from(&mut self.outlines, &mut other.outlines); - servo_dlist::append_from(&mut self.children, &mut other.children); + self.background_and_borders.append(&mut other.background_and_borders); + self.block_backgrounds_and_borders.append(&mut other.block_backgrounds_and_borders); + self.floats.append(&mut other.floats); + self.content.append(&mut other.content); + self.outlines.append(&mut other.outlines); + self.children.append(&mut other.children); } /// Merges all display items from all non-float stacking levels to the `float` stacking level. diff --git a/components/util/dlist.rs b/components/util/dlist.rs index f22c07268ba..f6df1b3d127 100644 --- a/components/util/dlist.rs +++ b/components/util/dlist.rs @@ -71,55 +71,9 @@ pub fn split(list: &mut DList) -> DList { } } -/// Appends the items in the other list to this one, leaving the other list empty. -#[inline] -pub fn append_from(this: &mut DList, other: &mut DList) { - unsafe { - let this = mem::transmute::<&mut DList,&mut RawDList>(this); - let other = mem::transmute::<&mut DList,&mut RawDList>(other); - if this.length == 0 { - this.head = mem::replace(&mut other.head, ptr::null_mut()); - this.tail = mem::replace(&mut other.tail, ptr::null_mut()); - this.length = mem::replace(&mut other.length, 0); - return - } - - let old_other_head = mem::replace(&mut other.head, ptr::null_mut()); - if old_other_head.is_null() { - return - } - (*old_other_head).prev = this.tail; - (*this.tail).next = old_other_head; - - this.tail = mem::replace(&mut other.tail, ptr::null_mut()); - this.length += other.length; - other.length = 0; - } -} - /// Prepends the items in the other list to this one, leaving the other list empty. #[inline] pub fn prepend_from(this: &mut DList, other: &mut DList) { - unsafe { - let this = mem::transmute::<&mut DList,&mut RawDList>(this); - let other = mem::transmute::<&mut DList,&mut RawDList>(other); - if this.length == 0 { - this.head = mem::replace(&mut other.head, ptr::null_mut()); - this.tail = mem::replace(&mut other.tail, ptr::null_mut()); - this.length = mem::replace(&mut other.length, 0); - return - } - - let old_other_tail = mem::replace(&mut other.tail, ptr::null_mut()); - if old_other_tail.is_null() { - return - } - (*old_other_tail).next = this.head; - (*this.head).prev = old_other_tail; - - this.head = mem::replace(&mut other.head, ptr::null_mut()); - this.length += other.length; - other.length = 0; - } + other.append(this); + mem::swap(this, other); } -