about summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--subx/010---vm.cc4
1 files changed, 4 insertions, 0 deletions
diff --git a/subx/010---vm.cc b/subx/010---vm.cc
index 24051ec4..47b2c3da 100644
--- a/subx/010---vm.cc
+++ b/subx/010---vm.cc
@@ -139,6 +139,10 @@ struct vma {
       #define align_upwards(x, align)  (((x)+(align)-1) & -(align))
       uint32_t new_size = align_upwards(result_size, align);
       #undef align_upwards
+      // grow at least 2x to maintain some amortized complexity guarantees
+      if (new_size < _data.size() * 2)
+        new_size = _data.size() * 2;
+      // never grow past the stated limit
       if (new_size > end-start)
         new_size = end-start;
       _data.resize(new_size);