core: Bytes have a minimum capacity of 16 bytes
authorAlexis Laferrière <alexis.laf@xymus.net>
Fri, 8 Sep 2017 14:43:32 +0000 (10:43 -0400)
committerAlexis Laferrière <alexis.laf@xymus.net>
Fri, 15 Sep 2017 12:25:57 +0000 (08:25 -0400)
Signed-off-by: Alexis Laferrière <alexis.laf@xymus.net>

lib/core/bytes.nit

index d53a76c..e375e60 100644 (file)
@@ -461,6 +461,7 @@ class Bytes
        redef fun enlarge(sz) do
                if capacity >= sz then return
                persisted = false
+               if capacity < 16 then capacity = 16
                while capacity < sz do capacity = capacity * 2 + 2
                var ns = new CString(capacity)
                items.copy_to(ns, length, 0, 0)