소스 검색

Merge the pushed block with block pushed by reserve

Patch by @nilset.
ticki 9 년 전
부모
커밋
265a3c7801
2개의 변경된 파일9개의 추가작업 그리고 0개의 파일을 삭제
  1. 8 0
      src/bookkeeper.rs
  2. 1 0
      src/lib.rs

+ 8 - 0
src/bookkeeper.rs

@@ -643,6 +643,14 @@ pub trait Allocator: ops::DerefMut<Target = Bookkeeper> {
                 self.free(x);
             }
 
+            // Try again to merge with last block on the off chance reserve pushed something we can
+            // merge with. This has actually happened in testing.
+            if let Some(x) = self.pool.last_mut() {
+                if x.merge_right(&mut block).is_ok() {
+                    return;
+                }
+            }
+
 
             // Merging failed. Note that trailing empty blocks are not allowed, hence the last block is
             // the only non-empty candidate which may be adjacent to `block`.

+ 1 - 0
src/lib.rs

@@ -23,6 +23,7 @@
         single_match_else, string_add, string_add_assign, wrong_pub_self_convention)]
 
 #[macro_use]
+#[no_link]
 extern crate unborrow;
 
 #[cfg(feature = "write")]