From 93c8e14d0c9bc233b2dcf213485b62a533b34580 Mon Sep 17 00:00:00 2001 From: Pierre-Marie Pédrot Date: Wed, 7 Mar 2018 12:03:47 -0300 Subject: More efficient reallocation of VM global tables. The previous code was mimicking what the C implementation was doing, which was a quadratic algorithm. We simply use the good old exponential reallocation strategy that is amortized O(1). --- kernel/csymtable.ml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'kernel/csymtable.ml') diff --git a/kernel/csymtable.ml b/kernel/csymtable.ml index 23b4194730..4f3cbf289d 100644 --- a/kernel/csymtable.ml +++ b/kernel/csymtable.ml @@ -47,7 +47,7 @@ let global_data = { let get_global_data () = Vmvalues.vm_global global_data.glob_val let realloc_global_data n = - let n = min (n + 0x100) Sys.max_array_length in + let n = min (2 * n + 0x100) Sys.max_array_length in let ans = Array.make n crazy_val in let src = global_data.glob_val in let () = Array.blit src 0 ans 0 (Array.length src) in -- cgit v1.2.3