From b9edb995c841f084c5644fb6e6b3565855ef7ae6 Mon Sep 17 00:00:00 2001 From: Michael Ripley Date: Mon, 12 Aug 2024 05:24:40 -0500 Subject: [PATCH] Restore with_capacity optimization --- src/builtins/register.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/builtins/register.rs b/src/builtins/register.rs index 1271b7b1ebe..dd6e9315b61 100644 --- a/src/builtins/register.rs +++ b/src/builtins/register.rs @@ -35,8 +35,9 @@ pub fn create_application_commands<'a, U: 'a, E: 'a>( } } - let mut commands_builder = Vec::new(); - for command in commands { + let command_iter = commands.into_iter(); + let mut commands_builder = Vec::with_capacity(command_iter.size_hint().0); + for command in command_iter { if let Some(slash_command) = command.create_as_slash_command() { commands_builder.push(slash_command); }