about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorBen Blum <bblum@andrew.cmu.edu>2012-07-26 21:16:35 -0400
committerBen Blum <bblum@andrew.cmu.edu>2012-07-26 21:20:02 -0400
commit9258053b5cce6dc752d57df2e0af14a335dfe7a4 (patch)
tree2c5190c64608d94fd103cb0abec605b9c59253ff /src
parent73ca5603bd1bf57e1734ff859299d7b10626a644 (diff)
Undo dlist's destructor-involving type structure in light of #3039
Diffstat (limited to 'src')
-rw-r--r--src/libcore/dlist.rs35
1 files changed, 9 insertions, 26 deletions
diff --git a/src/libcore/dlist.rs b/src/libcore/dlist.rs
index d11fc6efba4..ae75c04da72 100644
--- a/src/libcore/dlist.rs
+++ b/src/libcore/dlist.rs
@@ -18,28 +18,11 @@ enum dlist_node<T> = @{
     mut next: dlist_link<T>
 };
 
-class dlist_root<T> {
-    let mut size: uint;
-    let mut hd:   dlist_link<T>;
-    let mut tl:   dlist_link<T>;
-    new() {
-        self.size = 0; self.hd = none; self.tl = none;
-    }
-    drop {
-        /* FIXME (#3039) This doesn't work during task failure - the box
-         * annihilator might have killed some of our nodes already. This will
-         * be safe to uncomment when the box annihilator is safer. As is,
-         * this makes test_dlist_cyclic_link below crash the runtime.
-        // Empty the list. Not doing this explicitly would leave cyclic links
-        // around, not to be freed until cycle collection at task exit.
-        while self.hd.is_some() {
-            self.unlink(self.hd.get());
-        }
-        */
-    }
-}
-
-type dlist<T> = @dlist_root<T>;
+enum dlist<T> = @{
+    mut size: uint,
+    mut hd:   dlist_link<T>,
+    mut tl:   dlist_link<T>,
+};
 
 impl private_methods<T> for dlist_node<T> {
     pure fn assert_links() {
@@ -107,7 +90,7 @@ pure fn new_dlist_node<T>(+data: T) -> dlist_node<T> {
 
 /// Creates a new, empty dlist.
 pure fn new_dlist<T>() -> dlist<T> {
-    @unchecked { dlist_root() }
+    dlist(@{mut size: 0, mut hd: none, mut tl: none})
 }
 
 /// Creates a new dlist with a single element
@@ -134,7 +117,7 @@ fn concat<T>(lists: dlist<dlist<T>>) -> dlist<T> {
     result
 }
 
-impl private_methods<T> for dlist_root<T> {
+impl private_methods<T> for dlist<T> {
     pure fn new_link(-data: T) -> dlist_link<T> {
         some(dlist_node(@{data: data, mut linked: true,
                           mut prev: none, mut next: none}))
@@ -336,7 +319,7 @@ impl extensions<T> for dlist<T> {
      * to the other list's head. O(1).
      */
     fn append(them: dlist<T>) {
-        if box::ptr_eq(self, them) {
+        if box::ptr_eq(*self, *them) {
             fail ~"Cannot append a dlist to itself!"
         }
         if them.len() > 0 {
@@ -353,7 +336,7 @@ impl extensions<T> for dlist<T> {
      * list's tail to this list's head. O(1).
      */
     fn prepend(them: dlist<T>) {
-        if box::ptr_eq(self, them) {
+        if box::ptr_eq(*self, *them) {
             fail ~"Cannot prepend a dlist to itself!"
         }
         if them.len() > 0 {