changeset 40:456386366fc8

Only garbage collect when it is possible that buffer could grow
author Lewin Bormann <lewin@lewin-bormann.info>
date Sat, 08 Jun 2019 11:13:47 +0200
parents 0b3da01a454a
children 98b6d81573de
files src/state.rs
diffstat 1 files changed, 4 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/src/state.rs	Sat Jun 08 10:55:53 2019 +0200
+++ b/src/state.rs	Sat Jun 08 11:13:47 2019 +0200
@@ -141,6 +141,10 @@
 
     /// Remove data from buffer that is not hold by any parser anymore.
     fn maybe_gc(&mut self) -> bool {
+        // Disable garbage collection if buffer holds everything that it could ever hold.
+        if self.next.is_none() {
+            return false;
+        }
         match self.oldest_hold_count {
             None if self.current > 0 => {
                 if self.current < Self::GARBAGE_COLLECT_THRESHOLD {