Skip to content

Commit

Permalink
Direct collect boxed slices
Browse files Browse the repository at this point in the history
Co-authored-by: ira <[email protected]>
  • Loading branch information
MrGVSV and tim-blackbird committed Oct 19, 2022
1 parent df0c42b commit f124314
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 9 deletions.
7 changes: 2 additions & 5 deletions crates/bevy_reflect/src/enums/enum_trait.rs
Original file line number Diff line number Diff line change
Expand Up @@ -157,17 +157,14 @@ impl EnumInfo {
.map(|(index, variant)| (variant.name(), index))
.collect::<HashMap<_, _>>();

let variant_names = variants
.iter()
.map(|variant| variant.name())
.collect::<Vec<_>>();
let variant_names = variants.iter().map(|variant| variant.name()).collect();

Self {
name,
type_name: std::any::type_name::<TEnum>(),
type_id: TypeId::of::<TEnum>(),
variants: variants.to_vec().into_boxed_slice(),
variant_names: variant_names.into_boxed_slice(),
variant_names,
variant_indices,
#[cfg(feature = "documentation")]
docs: None,
Expand Down
4 changes: 2 additions & 2 deletions crates/bevy_reflect/src/enums/variants.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,11 +99,11 @@ 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::<Vec<_>>();
let field_names = fields.iter().map(|field| field.name()).collect();
Self {
name,
fields: fields.to_vec().into_boxed_slice(),
field_names: field_names.into_boxed_slice(),
field_names,
field_indices,
#[cfg(feature = "documentation")]
docs: None,
Expand Down
4 changes: 2 additions & 2 deletions crates/bevy_reflect/src/struct_trait.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,14 +94,14 @@ impl StructInfo {
.map(|(index, field)| (field.name(), index))
.collect::<HashMap<_, _>>();

let field_names = fields.iter().map(|field| field.name()).collect::<Vec<_>>();
let field_names = fields.iter().map(|field| field.name()).collect();

Self {
name,
type_name: std::any::type_name::<T>(),
type_id: TypeId::of::<T>(),
fields: fields.to_vec().into_boxed_slice(),
field_names: field_names.into_boxed_slice(),
field_names,
field_indices,
#[cfg(feature = "documentation")]
docs: None,
Expand Down

0 comments on commit f124314

Please sign in to comment.