diff --git a/src/std_fns.rs b/src/std_fns.rs index 315da3b..b4a8e88 100644 --- a/src/std_fns.rs +++ b/src/std_fns.rs @@ -906,7 +906,8 @@ pub fn str_to_mega_radix(stack: &mut Stack) -> OError { pub fn mega_to_str_radix(stack: &mut Stack) -> OError { require_int_on_stack!(radix, stack, "mega-to-str-radix"); require_on_stack!(mega, Mega, stack, "mega-to-str-radix"); - let mut result = Vec::new(); + // capacity because O(n) + let mut result = Vec::with_capacity((mega as f64).powf(1.0 / radix as f64) as usize + 2); let neg = mega < 0; let mut mega = mega; if neg {