Repository: bevyengine/bevy
File: crates/bevy_gltf/src/loader/mod.rs (Rust)

Code before:
        nodes_to_sort.sort_by_key(|(i, _)| *i);
        let nodes = nodes_to_sort
            .into_iter()
            .map(|(_, resolved)| resolved)
            .collect();

        let mut scenes = vec![];
        let mut named_scenes = <HashMap<_, _>>::default();
        let mut active_camera_found = false;
        for scene in gltf.scenes() {
            let mut err = None;
            let mut world = World::default();
            let mut node_index_to_entity_map = <HashMap<_, _>>::default();
            let mut entity_to_skin_index_map = EntityHashMap::default();
            let mut scene_load_context = load_context.begin_labeled_asset();

            let world_root_transform = convert_coordinates.scene_conversion_transform();

            let world_root_id = world
                .spawn((
                    world_root_transform,
                    Visibility::default(),
                    scene
                        .name()
                        .map(|name| Name::new(name.to_owned()))
                        .unwrap_or(Name::new(format!("Scene{}", scene.index()))),
                ))
                .with_children(|parent| {
                    for node in scene.nodes() {
                        let result = load_node(
                            &node,
                            parent,
                            load_context,
                            &mut scene_load_context,
                            settings,
                            &mut node_index_to_entity_map,
                            &mut entity_to_skin_index_map,
                            &mut active_camera_found,
                            &Transform::default(),
                            #[cfg(feature = "bevy_animation")]
                            &animation_roots,
                            #[cfg(feature = "bevy_animation")]
                            None,
                            &texture_handles,
                            &convert_coordinates,
                            &mut extensions,
                            skinned_mesh_bounds_policy,
                        );
                        if result.is_err() {
                            err = Some(result);
                            return;

Review comment (suggestion):
```suggestion
                        .unwrap_or_else(|| Name::new(format!("Scene{}", scene.index()))),
```

Minor optimization - avoids a redundant format when the name is set.

Code after:
            nodes.insert(node.index(), handle.clone());
            if let Some(name) = node.name() {
                named_nodes.insert(name.into(), handle);
            }
        }

        let mut nodes_to_sort = nodes.into_iter().collect::<Vec<_>>();
        nodes_to_sort.sort_by_key(|(i, _)| *i);
        let nodes = nodes_to_sort
            .into_iter()
            .map(|(_, resolved)| resolved)
            .collect();

        let mut scenes = vec![];
        let mut named_scenes = <HashMap<_, _>>::default();
        let mut active_camera_found = false;
        for scene in gltf.scenes() {
            let mut err = None;
            let mut world = World::default();
            let mut node_index_to_entity_map = <HashMap<_, _>>::default();
            let mut entity_to_skin_index_map = EntityHashMap::default();
            let mut scene_load_context = load_context.begin_labeled_asset();

            let world_root_transform = convert_coordinates.scene_conversion_transform();

            let world_root_id = world
                .spawn((
                    world_root_transform,
                    Visibility::default(),
                    Name::new(
                        scene
                            .name()
                            .map(ToOwned::to_owned)
                            .unwrap_or_else(|| format!("Scene{}", scene.index())),
                    ),
                ))
                .with_children(|parent| {
                    for node in scene.nodes() {
                        let result = load_node(
                            &node,
                            parent,
                            load_context,
                            &mut scene_load_context,
                            settings,
                            &mut node_index_to_entity_map,
                            &mut entity_to_skin_index_map,
                            &mut active_camera_found,
                            &Transform::default(),
                            #[cfg(feature = "bevy_animation")]
                            &animation_roots,
                            #[cfg(feature = "bevy_animation")]