]> git.lizzy.rs Git - rust.git/commitdiff
BTree: tweak internal comments
authorStein Somers <git@steinsomers.be>
Sun, 22 May 2022 11:46:54 +0000 (13:46 +0200)
committerStein Somers <git@steinsomers.be>
Wed, 8 Jun 2022 10:22:18 +0000 (12:22 +0200)
library/alloc/src/collections/btree/fix.rs
library/alloc/src/collections/btree/map/entry.rs

index c4861817dd05da395b86aa137136a194cf086b27..fd73fde2acb2df6f1cc25a52a94d11bdd663c1ae 100644 (file)
@@ -91,8 +91,8 @@ pub fn fix_left_border(&mut self) {
         }
     }
 
-    /// Stock up any underfull nodes on the right border of the tree.
-    /// The other nodes, those that are not the root nor a rightmost edge,
+    /// Stocks up any underfull nodes on the right border of the tree.
+    /// The other nodes, those that are neither the root nor a rightmost edge,
     /// must be prepared to have up to MIN_LEN elements stolen.
     pub fn fix_right_border_of_plentiful(&mut self) {
         let mut cur_node = self.borrow_mut();
index cacd06b5df153da6b6f629bc813c0ed1fb2d7202..e2749aac694c8227e8082a738a8327df12fbf8e4 100644 (file)
@@ -315,7 +315,7 @@ pub fn into_key(self) -> K {
     pub fn insert(self, value: V) -> &'a mut V {
         let out_ptr = match self.handle {
             None => {
-                // SAFETY: We have consumed self.handle and the reference returned.
+                // SAFETY: There is no tree yet so no reference to it exists.
                 let map = unsafe { self.dormant_map.awaken() };
                 let mut root = NodeRef::new_leaf();
                 let val_ptr = root.borrow_mut().push(self.key, value) as *mut V;
@@ -325,16 +325,17 @@ pub fn insert(self, value: V) -> &'a mut V {
             }
             Some(handle) => match handle.insert_recursing(self.key, value) {
                 (None, val_ptr) => {
-                    // SAFETY: We have consumed self.handle and the handle returned.
+                    // SAFETY: We have consumed self.handle.
                     let map = unsafe { self.dormant_map.awaken() };
                     map.length += 1;
                     val_ptr
                 }
                 (Some(ins), val_ptr) => {
                     drop(ins.left);
-                    // SAFETY: We have consumed self.handle and the reference returned.
+                    // SAFETY: We have consumed self.handle and dropped the
+                    // remaining reference to the tree, ins.left.
                     let map = unsafe { self.dormant_map.awaken() };
-                    let root = map.root.as_mut().unwrap();
+                    let root = map.root.as_mut().unwrap(); // same as ins.left
                     root.push_internal_level().push(ins.kv.0, ins.kv.1, ins.right);
                     map.length += 1;
                     val_ptr