bevy/crates/bevy_ecs/src/query
Carter Anderson 68606934e3 remove unsafe get_unchecked (and mut variant) from Tables and Archetypes (#1614)
Removes `get_unchecked` and `get_unchecked_mut` from `Tables` and `Archetypes` collections in favor of safe Index implementations. This fixes a safety error in `Archetypes::get_id_or_insert()` (which previously relied on TableId being valid to be safe ... the alternative was to make that method unsafe too). It also cuts down on a lot of unsafe and makes the code easier to look at. I'm not sure what changed since the last benchmark, but these numbers are more favorable than my last tests of similar changes. I didn't include the Components collection as those severely killed perf last time I tried. But this does inspire me to try again (just in a separate pr)! 

Note that the `simple_insert/bevy_unbatched` benchmark fluctuates a lot on both branches (this was also true for prior versions of bevy). It seems like the allocator has more variance for many small allocations. And `sparse_frag_iter/bevy` operates on such a small scale that 10% fluctuations are common.

Some benches do take a small hit here, but I personally think its worth it.

This also fixes a safety error in Query::for_each_mut, which needed to mutably borrow Query (aaahh!).  

![image](https://user-images.githubusercontent.com/2694663/110726926-2b52eb80-81cf-11eb-9ea3-bff951060c7c.png)
![image](https://user-images.githubusercontent.com/2694663/110726991-4c1b4100-81cf-11eb-9199-ca79bef0b9bd.png)
2021-03-11 18:38:22 +00:00
..
access.rs format comments (#1612) 2021-03-11 00:27:30 +00:00
fetch.rs remove unsafe get_unchecked (and mut variant) from Tables and Archetypes (#1614) 2021-03-11 18:38:22 +00:00
filter.rs remove unsafe get_unchecked (and mut variant) from Tables and Archetypes (#1614) 2021-03-11 18:38:22 +00:00
iter.rs remove unsafe get_unchecked (and mut variant) from Tables and Archetypes (#1614) 2021-03-11 18:38:22 +00:00
mod.rs Bevy ECS V2 (#1525) 2021-03-05 07:54:35 +00:00
state.rs remove unsafe get_unchecked (and mut variant) from Tables and Archetypes (#1614) 2021-03-11 18:38:22 +00:00