mirror of
https://github.com/bevyengine/bevy
synced 2024-11-25 22:20:20 +00:00
ecs: slightly improve perf with inlining changes
This commit is contained in:
parent
a7bab755ee
commit
88781007b0
3 changed files with 7 additions and 6 deletions
|
@ -106,6 +106,7 @@ impl Archetype {
|
|||
}
|
||||
|
||||
#[allow(missing_docs)]
|
||||
#[inline]
|
||||
pub fn get<T: Component>(&self) -> Option<NonNull<T>> {
|
||||
let state = self.state.get(&TypeId::of::<T>())?;
|
||||
Some(unsafe {
|
||||
|
|
|
@ -72,9 +72,11 @@ impl Query for Entity {
|
|||
|
||||
impl<'a> Fetch<'a> for EntityFetch {
|
||||
type Item = Entity;
|
||||
#[inline]
|
||||
fn access(_archetype: &Archetype) -> Option<Access> {
|
||||
Some(Access::Iterate)
|
||||
}
|
||||
#[inline]
|
||||
fn borrow(_archetype: &Archetype) {}
|
||||
#[inline]
|
||||
unsafe fn get(archetype: &'a Archetype, offset: usize) -> Option<Self> {
|
||||
|
@ -82,6 +84,7 @@ impl<'a> Fetch<'a> for EntityFetch {
|
|||
archetype.entities().as_ptr().add(offset),
|
||||
)))
|
||||
}
|
||||
#[inline]
|
||||
fn release(_archetype: &Archetype) {}
|
||||
|
||||
#[inline]
|
||||
|
@ -152,7 +155,6 @@ impl<'a, T: Component> Fetch<'a> for FetchWrite<T> {
|
|||
fn borrow(archetype: &Archetype) {
|
||||
archetype.borrow_mut::<T>();
|
||||
}
|
||||
#[inline]
|
||||
unsafe fn get(archetype: &'a Archetype, offset: usize) -> Option<Self> {
|
||||
archetype
|
||||
.get::<T>()
|
||||
|
@ -162,7 +164,6 @@ impl<'a, T: Component> Fetch<'a> for FetchWrite<T> {
|
|||
archetype.release_mut::<T>();
|
||||
}
|
||||
|
||||
#[inline]
|
||||
unsafe fn next(&mut self) -> &'a mut T {
|
||||
let x = self.0.as_ptr();
|
||||
self.0 = NonNull::new_unchecked(x.add(1));
|
||||
|
@ -517,7 +518,6 @@ struct ChunkIter<Q: Query> {
|
|||
}
|
||||
|
||||
impl<Q: Query> ChunkIter<Q> {
|
||||
#[inline]
|
||||
unsafe fn next<'a, 'w>(&mut self) -> Option<<Q::Fetch as Fetch<'a>>::Item> {
|
||||
if self.len == 0 {
|
||||
return None;
|
||||
|
|
|
@ -53,6 +53,7 @@ where
|
|||
self.thread_local_execution
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn run(&mut self, world: &World, resources: &Resources) {
|
||||
(self.func)(world, resources, &self.archetype_access, &mut self.state);
|
||||
}
|
||||
|
@ -102,9 +103,8 @@ macro_rules! impl_into_foreach_system {
|
|||
<<($($resource,)*) as ResourceQuery>::Fetch as FetchResource>::borrow(&resources.resource_archetypes);
|
||||
{
|
||||
let ($($resource,)*) = resources.query_system::<($($resource,)*)>(id);
|
||||
let commands = state.clone();
|
||||
for ($($component,)*) in world.query::<($($component,)*)>().iter() {
|
||||
fn_call!(self, ($($commands, commands)*), ($($resource),*), ($($component),*))
|
||||
fn_call!(self, ($($commands, state)*), ($($resource),*), ($($component),*))
|
||||
}
|
||||
}
|
||||
<<($($resource,)*) as ResourceQuery>::Fetch as FetchResource>::release(&resources.resource_archetypes);
|
||||
|
@ -242,7 +242,7 @@ macro_rules! impl_into_query_system {
|
|||
i += 1;
|
||||
)*
|
||||
|
||||
let commands = state.commands.clone();
|
||||
let commands = &state.commands;
|
||||
fn_call!(self, ($($commands, commands)*), ($($resource),*), ($($query),*))
|
||||
}
|
||||
<<($($resource,)*) as ResourceQuery>::Fetch as FetchResource>::release(&resources.resource_archetypes);
|
||||
|
|
Loading…
Reference in a new issue