Skip to content

Commit 2ca008a

Browse files
committed
Remove unnecessary reverse
1 parent 0bd2e31 commit 2ca008a

File tree

1 file changed

+30
-31
lines changed

1 file changed

+30
-31
lines changed

crates/bevy_ui/src/update.rs

+30-31
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ pub fn ui_z_system(
1616
.iter()
1717
.map(|e| (e, UI_BASE_DEPTH))
1818
.collect::<Vec<(Entity, f32)>>();
19-
node_stack.reverse();
2019
while let Some((node, parent_global_z)) = node_stack.pop() {
2120
current_global_z += UI_Z_STEP;
2221
let local_z = current_global_z - parent_global_z;
@@ -58,7 +57,18 @@ mod tests {
5857
let mut commands = Commands::default();
5958
commands.set_entity_reserver(world.get_entity_reserver());
6059

61-
commands.spawn(node_with_transform("0"));
60+
commands
61+
.spawn(node_without_transform("0"))
62+
.with_children(|parent| {
63+
parent
64+
.spawn(node_with_transform("0-0"))
65+
.with_children(|_parent| ());
66+
parent
67+
.spawn(node_with_transform("0-1"))
68+
.with_children(|parent| {
69+
parent.spawn(node_with_transform("0-1-0"));
70+
});
71+
});
6272

6373
commands
6474
.spawn(node_with_transform("1"))
@@ -83,19 +93,8 @@ mod tests {
8393
});
8494
parent.spawn(node_with_transform("1-3"));
8595
});
96+
commands.spawn(node_with_transform("2"));
8697

87-
commands
88-
.spawn(node_without_transform("2"))
89-
.with_children(|parent| {
90-
parent
91-
.spawn(node_with_transform("2-0"))
92-
.with_children(|_parent| ());
93-
parent
94-
.spawn(node_with_transform("2-1"))
95-
.with_children(|parent| {
96-
parent.spawn(node_with_transform("2-1-0"));
97-
});
98-
});
9998
commands.apply(&mut world, &mut resources);
10099

101100
let mut schedule = Schedule::default();
@@ -110,23 +109,23 @@ mod tests {
110109
.collect::<Vec<(String, u32)>>();
111110
actual_result.sort_unstable_by_key(|(name, _)| name.clone());
112111
let expected_result = vec![
113-
("0".to_owned(), 1), // total_depth 1
114-
("1".to_owned(), 2), // total_depth 2
115-
("1-0".to_owned(), 1), // total_depth 3
116-
("1-0-0".to_owned(), 1), // total_depth 4
117-
// 1-0-1 has no transform total_depth 5
118-
("1-0-2".to_owned(), 3), // total_depth 6
119-
("1-1".to_owned(), 5), // total_depth 7
120-
// 1-2 has no transform total_depth 8
121-
("1-2-0".to_owned(), 1), // total_depth 9
122-
("1-2-1".to_owned(), 2), // total_depth 10
123-
("1-2-2".to_owned(), 3), // total_depth 11
124-
("1-2-3".to_owned(), 4), // total_depth 12
125-
("1-3".to_owned(), 11), // total_depth 13
126-
// 2 has no transform total_depth 14
127-
("2-0".to_owned(), 1), // total_depth 15
128-
("2-1".to_owned(), 2), // total_depth 16
129-
("2-1-0".to_owned(), 1), // total_depth 17
112+
// 0 has no transform total_depth 1
113+
("0-0".to_owned(), 1), // total_depth 2
114+
("0-1".to_owned(), 2), // total_depth 3
115+
("0-1-0".to_owned(), 1), // total_depth 4
116+
("1".to_owned(), 5), // total_depth 5
117+
("1-0".to_owned(), 1), // total_depth 6
118+
("1-0-0".to_owned(), 1), // total_depth 7
119+
// 1-0-1 has no transform total_depth 8
120+
("1-0-2".to_owned(), 3), // total_depth 9
121+
("1-1".to_owned(), 5), // total_depth 10
122+
// 1-2 has no transform total_depth 11
123+
("1-2-0".to_owned(), 1), // total_depth 12
124+
("1-2-1".to_owned(), 2), // total_depth 13
125+
("1-2-2".to_owned(), 3), // total_depth 14
126+
("1-2-3".to_owned(), 4), // total_depth 15
127+
("1-3".to_owned(), 11), // total depth 16
128+
("2".to_owned(), 17), // total_depth 17
130129
];
131130
assert_eq!(actual_result, expected_result);
132131
}

0 commit comments

Comments
 (0)