Skip to content

Commit

Permalink
Direct collect boxed slices
Browse files Browse the repository at this point in the history
Co-authored-by: ira <JustTheCoolDude@gmail.com>
  • Loading branch information
MrGVSV and tim-blackbird committed Oct 17, 2022
1 parent 7bd305d commit 06c49d3
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 @@ -155,17 +155,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,
}
}
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 @@ -87,11 +87,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,
}
}
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 @@ -92,14 +92,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,
}
}
Expand Down

0 comments on commit 06c49d3

Please sign in to comment.