Address MR 3756 review comments.

This commit is contained in:
Avi Weinstock 2023-01-14 15:37:31 -05:00
parent 78845a0d73
commit a871d3880b
4 changed files with 6 additions and 10 deletions

1
Cargo.lock generated
View File

@ -6720,6 +6720,7 @@ dependencies = [
"fxhash",
"hashbrown 0.12.3",
"indexmap",
"itertools",
"kiddo 0.1.7",
"lazy_static",
"num-derive",

View File

@ -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"

View File

@ -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<Item = &Buff> + '_ {
self.kinds.iter().flat_map(move |(kind, ids)| {
if kind.stacks() {
Box::new(ids.iter().filter_map(|id| self.buffs.get(id)))
as Box<dyn Iterator<Item = &Buff>>
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())
}
})
}

View File

@ -250,13 +250,7 @@ impl<'a> System<'a> for Sys {
.iter()
.map(|(kind, ids)| (*kind, ids.clone()))
.collect::<Vec<(BuffKind, Vec<BuffId>)>>();
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() {