From 48842457c1f0026685aac459a812c75f9a83132f Mon Sep 17 00:00:00 2001 From: vaclavt Date: Sat, 15 Jan 2022 13:17:49 +0100 Subject: [PATCH] reserve capacity in advance of loop --- ml.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ml.cpp b/ml.cpp index a913b88..7efee13 100644 --- a/ml.cpp +++ b/ml.cpp @@ -1941,7 +1941,8 @@ MlValue range(std::vector args, MlEnvironment &env) { if (low >= high) return MlValue(result); - while (low < high) { + result.reserve(high.as_int() - low.as_int()); + while (low < high) { // use MlValue to keep number datatype result.push_back(low); low = low + MlValue(1l); }