Ver código fonte

Merge the pushed block with block pushed by reserve

Patch by @nilset.
ticki 8 anos atrás
pai
commit
265a3c7801
2 arquivos alterados com 9 adições e 0 exclusões
  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")]