浏览代码

Short circuit in case of empty block (fix #12)

ticki 8 年之前
父节点
当前提交
a322cb5f18
共有 1 个文件被更改,包括 4 次插入1 次删除
  1. 4 1
      src/bookkeeper.rs

+ 4 - 1
src/bookkeeper.rs

@@ -396,7 +396,10 @@ impl Bookkeeper {
     /// See [`free`](#method.free) for more information.
     /// See [`free`](#method.free) for more information.
     #[inline]
     #[inline]
     fn free_ind(&mut self, ind: usize, mut block: Block) {
     fn free_ind(&mut self, ind: usize, mut block: Block) {
-        /// Assertions...
+        // Short circuit in case of empty block.
+        if block.is_empty() { return; }
+
+        // Assertions...
         debug_assert!(self.find(&block) == ind, "Block is not inserted at the appropriate index.");
         debug_assert!(self.find(&block) == ind, "Block is not inserted at the appropriate index.");
 
 
         // Try to merge left, and then right.
         // Try to merge left, and then right.