From f130c8676864f13b9aa825370d47319846bc559f Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Fri, 22 May 2026 15:02:22 +0000 Subject: [PATCH] =?UTF-8?q?=E2=9A=A1=20Reserve=20vector=20capacity=20in=20?= =?UTF-8?q?const=5Froll=5Ftable::init?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Adding a pre-allocation vector reservation prevents multiple memory allocations during vector growth as the vector is populated. Co-authored-by: perim <436583+perim@users.noreply.github.com> --- dice.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/dice.cpp b/dice.cpp index 17193a0..34bf2b8 100644 --- a/dice.cpp +++ b/dice.cpp @@ -15,6 +15,7 @@ void const_roll_table::init(const std::vector& weights) std::queue small; std::queue large; std::vector w; + w.reserve(size); for (int i : weights) { w.push_back(i * size);