Skip to content

Commit 16bbc33

Browse files
fix unsafe, add release guide, run all tests for uncached queries
1 parent ef9ff96 commit 16bbc33

File tree

12 files changed

+311
-147
lines changed

12 files changed

+311
-147
lines changed

crates/bevy_ecs/Cargo.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,10 @@ bevy_debug_stepping = []
5252
## This will often provide more detailed error messages.
5353
track_location = []
5454

55+
## Makes queries become uncached by default.
56+
## Mostly useful for unit tests.
57+
query_uncached_default = []
58+
5559
# Executor Backend
5660

5761
## Uses `async-executor` as a task execution backend.

crates/bevy_ecs/src/entity_disabling.rs

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@
9797
//! [`Query` performance]: crate::prelude::Query#performance
9898
9999
use crate::{
100-
component::{ComponentId, Components, StorageType},
100+
component::ComponentId,
101101
query::FilteredAccess,
102102
world::{FromWorld, World},
103103
};
@@ -248,14 +248,6 @@ impl DefaultQueryFilters {
248248
}
249249
}
250250
}
251-
252-
pub(super) fn is_dense(&self, components: &Components) -> bool {
253-
self.disabling_ids().all(|component_id| {
254-
components
255-
.get_info(component_id)
256-
.is_some_and(|info| info.storage_type() == StorageType::Table)
257-
})
258-
}
259251
}
260252

261253
#[cfg(test)]

crates/bevy_ecs/src/lib.rs

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,10 @@ pub mod prelude {
8888
message::{Message, MessageMutator, MessageReader, MessageWriter, Messages},
8989
name::{Name, NameOrEntity},
9090
observer::{Observer, On, Trigger},
91-
query::{Added, Allow, AnyOf, Changed, Has, Or, QueryBuilder, QueryState, With, Without},
91+
query::{
92+
Added, Allow, AnyOf, Changed, Has, Or, QueryBuilder, QueryState, UncachedQueryState,
93+
With, Without,
94+
},
9295
related,
9396
relationship::RelationshipTarget,
9497
resource::Resource,
@@ -101,7 +104,7 @@ pub mod prelude {
101104
Command, Commands, Deferred, EntityCommand, EntityCommands, If, In, InMut, InRef,
102105
IntoSystem, Local, NonSend, NonSendMut, ParamSet, Populated, Query, ReadOnlySystem,
103106
Res, ResMut, Single, System, SystemIn, SystemInput, SystemParamBuilder,
104-
SystemParamFunction,
107+
SystemParamFunction, UncachedQuery,
105108
},
106109
world::{
107110
EntityMut, EntityRef, EntityWorldMut, FilteredResources, FilteredResourcesMut,
@@ -475,8 +478,12 @@ mod tests {
475478
assert_eq!(ents, &[(e, A(123))]);
476479

477480
let f = world.spawn((TableStored("def"), A(456), B(1))).id();
478-
let ents = query.iter(&world).map(|(e, &i)| (e, i)).collect::<Vec<_>>();
479-
assert_eq!(ents, &[(e, A(123)), (f, A(456))]);
481+
let ents = query
482+
.iter(&world)
483+
.map(|(e, &i)| (e, i))
484+
.collect::<HashSet<_>>();
485+
assert!(ents.contains(&(e, A(123))));
486+
assert!(ents.contains(&(f, A(456))));
480487
}
481488

482489
#[test]

0 commit comments

Comments
 (0)