From dacd3f84c7d8057e8f7a22f4e08cd37f51064cb7 Mon Sep 17 00:00:00 2001 From: Vito Caputo Date: Sat, 7 Jan 2017 18:40:38 -0800 Subject: sparkler: don't age or sim on empty children either More of 86bc322, eliminate per-particle unnecessary calls --- modules/sparkler/particles.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'modules') diff --git a/modules/sparkler/particles.c b/modules/sparkler/particles.c index bb431a6..69f55dd 100644 --- a/modules/sparkler/particles.c +++ b/modules/sparkler/particles.c @@ -260,7 +260,8 @@ static inline particle_status_t _particles_sim(particles_t *particles, list_head if ((s = particle_sim(particles, &p->public)) == PARTICLE_ALIVE) { ret = PARTICLE_ALIVE; - if (_particles_sim(particles, &p->children) == PARTICLE_ALIVE) { + if (!list_empty(&p->children) && + _particles_sim(particles, &p->children) == PARTICLE_ALIVE) { ret = PARTICLE_ALIVE; } } else { @@ -326,7 +327,9 @@ static inline void _particles_age(particles_t *particles, list_head_t *list) bsp_move_occupant(particles->bsp, &p->public.occupant, &p->props.position); } - _particles_age(particles, &p->children); + if (!list_empty(&p->children)) { + _particles_age(particles, &p->children); + } } } -- cgit v1.2.3