From 1d330f48701fa0d053c6bf5278d3aa6f9ee448c7 Mon Sep 17 00:00:00 2001 From: Gino Valente <49806985+MrGVSV@users.noreply.github.com> Date: Mon, 31 Oct 2022 14:23:24 -0700 Subject: [PATCH] Simplify name collection MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: François --- crates/bevy_reflect/src/enums/enum_trait.rs | 2 +- crates/bevy_reflect/src/enums/variants.rs | 2 +- crates/bevy_reflect/src/struct_trait.rs | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/crates/bevy_reflect/src/enums/enum_trait.rs b/crates/bevy_reflect/src/enums/enum_trait.rs index 5d5a04c91d53a9..2f77428c344f52 100644 --- a/crates/bevy_reflect/src/enums/enum_trait.rs +++ b/crates/bevy_reflect/src/enums/enum_trait.rs @@ -157,7 +157,7 @@ impl EnumInfo { .map(|(index, variant)| (variant.name(), index)) .collect::>(); - let variant_names = variants.iter().map(|variant| variant.name()).collect(); + let variant_names = variant_indices.keys().collect(); Self { name, diff --git a/crates/bevy_reflect/src/enums/variants.rs b/crates/bevy_reflect/src/enums/variants.rs index 6901474041408f..ef5455f29d2297 100644 --- a/crates/bevy_reflect/src/enums/variants.rs +++ b/crates/bevy_reflect/src/enums/variants.rs @@ -99,7 +99,7 @@ impl StructVariantInfo { /// Create a new [`StructVariantInfo`]. pub fn new(name: &'static str, fields: &[NamedField]) -> Self { let field_indices = Self::collect_field_indices(fields); - let field_names = fields.iter().map(|field| field.name()).collect(); + let field_names = field_indices.keys().collect(); Self { name, fields: fields.to_vec().into_boxed_slice(), diff --git a/crates/bevy_reflect/src/struct_trait.rs b/crates/bevy_reflect/src/struct_trait.rs index 71736d5c5ebc92..80248183ef21f7 100644 --- a/crates/bevy_reflect/src/struct_trait.rs +++ b/crates/bevy_reflect/src/struct_trait.rs @@ -94,7 +94,7 @@ impl StructInfo { .map(|(index, field)| (field.name(), index)) .collect::>(); - let field_names = fields.iter().map(|field| field.name()).collect(); + let field_names = field_indices.keys().collect(); Self { name,