Skip to content

Commit

Permalink
⚡️ Prevent allocating static data
Browse files Browse the repository at this point in the history
  • Loading branch information
rster2002 committed Nov 9, 2024
1 parent ac14dd8 commit 1dda11a
Show file tree
Hide file tree
Showing 3 changed files with 207 additions and 207 deletions.
6 changes: 3 additions & 3 deletions src/modules/exobiology/models/spawn_condition.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use crate::modules::galaxy::{
};

#[derive(Debug)]
pub enum SpawnCondition {
pub enum SpawnCondition<'a> {
MinMeanTemperature(f32),
MaxMeanTemperature(f32),
NoAtmosphere,
Expand Down Expand Up @@ -38,6 +38,6 @@ pub enum SpawnCondition {

Special,

Any(Vec<SpawnCondition>),
All(Vec<SpawnCondition>),
Any(&'a [SpawnCondition<'a>]),
All(&'a [SpawnCondition<'a>]),
}
4 changes: 2 additions & 2 deletions src/modules/exobiology/models/species.rs
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ pub enum Species {
}

Check warning on line 184 in src/modules/exobiology/models/species.rs

View workflow job for this annotation

GitHub Actions / cargo fmt

Diff in /home/runner/work/ed-journals/ed-journals/src/modules/exobiology/models/species.rs

lazy_static! {
static ref UNKNOWN_SPAWN_CONDITIONS: Vec<SpawnCondition> = vec![SpawnCondition::Special,];
static ref UNKNOWN_SPAWN_CONDITIONS: &'static [SpawnCondition<'static>] = &[SpawnCondition::Special];
}

impl Species {
Expand All @@ -195,7 +195,7 @@ impl Species {
matches!(self, Species::Unknown(_))
}

pub fn spawn_conditions(&self) -> &Vec<SpawnCondition> {
pub fn spawn_conditions(&self) -> &[SpawnCondition<'_>] {
#[cfg(feature = "allow-unknown")]
if let Species::Unknown(_) = self {
return &UNKNOWN_SPAWN_CONDITIONS;
Expand Down
Loading

0 comments on commit 1dda11a

Please sign in to comment.