Skip to content

Commit

Permalink
Remove unnecessary reverse
Browse files Browse the repository at this point in the history
  • Loading branch information
svents committed Nov 21, 2020
1 parent 0bd2e31 commit 2ca008a
Showing 1 changed file with 30 additions and 31 deletions.
61 changes: 30 additions & 31 deletions crates/bevy_ui/src/update.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ pub fn ui_z_system(
.iter()
.map(|e| (e, UI_BASE_DEPTH))
.collect::<Vec<(Entity, f32)>>();
node_stack.reverse();
while let Some((node, parent_global_z)) = node_stack.pop() {
current_global_z += UI_Z_STEP;
let local_z = current_global_z - parent_global_z;
Expand Down Expand Up @@ -58,7 +57,18 @@ mod tests {
let mut commands = Commands::default();
commands.set_entity_reserver(world.get_entity_reserver());

commands.spawn(node_with_transform("0"));
commands
.spawn(node_without_transform("0"))
.with_children(|parent| {
parent
.spawn(node_with_transform("0-0"))
.with_children(|_parent| ());
parent
.spawn(node_with_transform("0-1"))
.with_children(|parent| {
parent.spawn(node_with_transform("0-1-0"));
});
});

commands
.spawn(node_with_transform("1"))
Expand All @@ -83,19 +93,8 @@ mod tests {
});
parent.spawn(node_with_transform("1-3"));
});
commands.spawn(node_with_transform("2"));

commands
.spawn(node_without_transform("2"))
.with_children(|parent| {
parent
.spawn(node_with_transform("2-0"))
.with_children(|_parent| ());
parent
.spawn(node_with_transform("2-1"))
.with_children(|parent| {
parent.spawn(node_with_transform("2-1-0"));
});
});
commands.apply(&mut world, &mut resources);

let mut schedule = Schedule::default();
Expand All @@ -110,23 +109,23 @@ mod tests {
.collect::<Vec<(String, u32)>>();
actual_result.sort_unstable_by_key(|(name, _)| name.clone());
let expected_result = vec![
("0".to_owned(), 1), // total_depth 1
("1".to_owned(), 2), // total_depth 2
("1-0".to_owned(), 1), // total_depth 3
("1-0-0".to_owned(), 1), // total_depth 4
// 1-0-1 has no transform total_depth 5
("1-0-2".to_owned(), 3), // total_depth 6
("1-1".to_owned(), 5), // total_depth 7
// 1-2 has no transform total_depth 8
("1-2-0".to_owned(), 1), // total_depth 9
("1-2-1".to_owned(), 2), // total_depth 10
("1-2-2".to_owned(), 3), // total_depth 11
("1-2-3".to_owned(), 4), // total_depth 12
("1-3".to_owned(), 11), // total_depth 13
// 2 has no transform total_depth 14
("2-0".to_owned(), 1), // total_depth 15
("2-1".to_owned(), 2), // total_depth 16
("2-1-0".to_owned(), 1), // total_depth 17
// 0 has no transform total_depth 1
("0-0".to_owned(), 1), // total_depth 2
("0-1".to_owned(), 2), // total_depth 3
("0-1-0".to_owned(), 1), // total_depth 4
("1".to_owned(), 5), // total_depth 5
("1-0".to_owned(), 1), // total_depth 6
("1-0-0".to_owned(), 1), // total_depth 7
// 1-0-1 has no transform total_depth 8
("1-0-2".to_owned(), 3), // total_depth 9
("1-1".to_owned(), 5), // total_depth 10
// 1-2 has no transform total_depth 11
("1-2-0".to_owned(), 1), // total_depth 12
("1-2-1".to_owned(), 2), // total_depth 13
("1-2-2".to_owned(), 3), // total_depth 14
("1-2-3".to_owned(), 4), // total_depth 15
("1-3".to_owned(), 11), // total depth 16
("2".to_owned(), 17), // total_depth 17
];
assert_eq!(actual_result, expected_result);
}
Expand Down

0 comments on commit 2ca008a

Please sign in to comment.