mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
avoid one allocation, spotted by imbris
This commit is contained in:
parent
3cc88f9b1d
commit
589ceb6d38
@ -1314,22 +1314,18 @@ impl ParticleMgr {
|
||||
|smoker| smoker.strength,
|
||||
);
|
||||
if let Ok(chosen) = chosen {
|
||||
let mut smoke_particles: Vec<Particle> = chosen
|
||||
.map(|smoker| {
|
||||
Particle::new(
|
||||
Duration::from_secs_f32(lifetime),
|
||||
time,
|
||||
if rng.gen::<f32>() > smoker.dry_chance {
|
||||
ParticleMode::BlackSmoke
|
||||
} else {
|
||||
ParticleMode::CampfireSmoke
|
||||
},
|
||||
smoker.position.map(|e: i32| e as f32 + rng.gen::<f32>()),
|
||||
)
|
||||
})
|
||||
.collect();
|
||||
|
||||
self.particles.append(&mut smoke_particles);
|
||||
self.particles.extend(chosen.map(|smoker| {
|
||||
Particle::new(
|
||||
Duration::from_secs_f32(lifetime),
|
||||
time,
|
||||
if rng.gen::<f32>() > smoker.dry_chance {
|
||||
ParticleMode::BlackSmoke
|
||||
} else {
|
||||
ParticleMode::CampfireSmoke
|
||||
},
|
||||
smoker.position.map(|e: i32| e as f32 + rng.gen::<f32>()),
|
||||
)
|
||||
}));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user