diff --git a/Cargo.lock b/Cargo.lock index a09b0cd784..5694988420 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -6720,6 +6720,7 @@ dependencies = [ "fxhash", "hashbrown 0.12.3", "indexmap", + "itertools", "kiddo 0.1.7", "lazy_static", "num-derive", diff --git a/common/Cargo.toml b/common/Cargo.toml index 111c3f403e..10c2d80864 100644 --- a/common/Cargo.toml +++ b/common/Cargo.toml @@ -29,6 +29,7 @@ serde = { version = "1.0.110", features = ["derive", "rc"] } vek = { version = "0.15.8", features = ["serde"] } chrono = "0.4.22" chrono-tz = "0.6" +itertools = "0.10" sha2 = "0.10" serde_json = "1.0.50" diff --git a/common/src/comp/buff.rs b/common/src/comp/buff.rs index 0a444c900c..7be0eeacad 100644 --- a/common/src/comp/buff.rs +++ b/common/src/comp/buff.rs @@ -3,6 +3,7 @@ use crate::uid::Uid; use core::{cmp::Ordering, time::Duration}; #[cfg(not(target_arch = "wasm32"))] use hashbrown::HashMap; +use itertools::Either; use serde::{Deserialize, Serialize}; #[cfg(not(target_arch = "wasm32"))] use specs::{Component, DerefFlaggedStorage, VecStorage}; @@ -561,10 +562,9 @@ impl Buffs { pub fn iter_active(&self) -> impl Iterator + '_ { self.kinds.iter().flat_map(move |(kind, ids)| { if kind.stacks() { - Box::new(ids.iter().filter_map(|id| self.buffs.get(id))) - as Box> + Either::Left(ids.iter().filter_map(|id| self.buffs.get(id))) } else { - Box::new(self.buffs.get(&ids[0]).into_iter()) + Either::Right(self.buffs.get(&ids[0]).into_iter()) } }) } diff --git a/common/systems/src/buff.rs b/common/systems/src/buff.rs index 5c763b4f59..0961240132 100644 --- a/common/systems/src/buff.rs +++ b/common/systems/src/buff.rs @@ -250,13 +250,7 @@ impl<'a> System<'a> for Sys { .iter() .map(|(kind, ids)| (*kind, ids.clone())) .collect::)>>(); - buff_kinds.sort_by_key(|(kind, _)| { - if kind.affects_subsequent_buffs() { - 0 - } else { - 1 - } - }); + buff_kinds.sort_by_key(|(kind, _)| !kind.affects_subsequent_buffs()); for (buff_kind, buff_ids) in buff_kinds.into_iter() { let mut active_buff_ids = Vec::new(); if buff_kind.stacks() {