remove Box from ExclusiveSystemFn (#3063)
Minor refactor to remove the boxing of the function pointer stored in ExclusiveSystemFn.
This commit is contained in:
parent
91c3b210a2
commit
225d6a138f
@ -78,7 +78,10 @@ impl IntoSystemDescriptor<()> for ExclusiveSystemDescriptor {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl IntoSystemDescriptor<()> for ExclusiveSystemFn {
|
impl<F> IntoSystemDescriptor<()> for ExclusiveSystemFn<F>
|
||||||
|
where
|
||||||
|
F: FnMut(&mut crate::prelude::World) + Send + Sync + 'static,
|
||||||
|
{
|
||||||
fn into_descriptor(self) -> SystemDescriptor {
|
fn into_descriptor(self) -> SystemDescriptor {
|
||||||
new_exclusive_descriptor(Box::new(self)).into_descriptor()
|
new_exclusive_descriptor(Box::new(self)).into_descriptor()
|
||||||
}
|
}
|
||||||
|
@ -15,13 +15,16 @@ pub trait ExclusiveSystem: Send + Sync + 'static {
|
|||||||
fn check_change_tick(&mut self, change_tick: u32);
|
fn check_change_tick(&mut self, change_tick: u32);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct ExclusiveSystemFn {
|
pub struct ExclusiveSystemFn<F> {
|
||||||
func: Box<dyn FnMut(&mut World) + Send + Sync + 'static>,
|
func: F,
|
||||||
name: Cow<'static, str>,
|
name: Cow<'static, str>,
|
||||||
last_change_tick: u32,
|
last_change_tick: u32,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ExclusiveSystem for ExclusiveSystemFn {
|
impl<F> ExclusiveSystem for ExclusiveSystemFn<F>
|
||||||
|
where
|
||||||
|
F: FnMut(&mut World) + Send + Sync + 'static,
|
||||||
|
{
|
||||||
fn name(&self) -> Cow<'static, str> {
|
fn name(&self) -> Cow<'static, str> {
|
||||||
self.name.clone()
|
self.name.clone()
|
||||||
}
|
}
|
||||||
@ -52,13 +55,13 @@ pub trait IntoExclusiveSystem<Params, SystemType> {
|
|||||||
fn exclusive_system(self) -> SystemType;
|
fn exclusive_system(self) -> SystemType;
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<F> IntoExclusiveSystem<&mut World, ExclusiveSystemFn> for F
|
impl<F> IntoExclusiveSystem<&mut World, ExclusiveSystemFn<F>> for F
|
||||||
where
|
where
|
||||||
F: FnMut(&mut World) + Send + Sync + 'static,
|
F: FnMut(&mut World) + Send + Sync + 'static,
|
||||||
{
|
{
|
||||||
fn exclusive_system(self) -> ExclusiveSystemFn {
|
fn exclusive_system(self) -> ExclusiveSystemFn<F> {
|
||||||
ExclusiveSystemFn {
|
ExclusiveSystemFn {
|
||||||
func: Box::new(self),
|
func: self,
|
||||||
name: core::any::type_name::<F>().into(),
|
name: core::any::type_name::<F>().into(),
|
||||||
last_change_tick: 0,
|
last_change_tick: 0,
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user