mirror of
https://codeberg.org/demostf/parser.git
synced 2026-06-03 10:14:06 +02:00
dedup props with baselines
This commit is contained in:
parent
cf9cb48267
commit
aca7177374
1 changed files with 12 additions and 6 deletions
|
|
@ -10,6 +10,7 @@ use crate::demo::sendprop::{SendProp, SendPropIdentifier, SendPropValue};
|
||||||
use crate::{Parse, ParseError, ParserState, ReadResult, Result, Stream};
|
use crate::{Parse, ParseError, ParserState, ReadResult, Result, Stream};
|
||||||
use parse_display::{Display, FromStr};
|
use parse_display::{Display, FromStr};
|
||||||
use std::cmp::{min, Ordering};
|
use std::cmp::{min, Ordering};
|
||||||
|
use std::collections::HashSet;
|
||||||
|
|
||||||
use itertools::Either;
|
use itertools::Either;
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
|
|
@ -158,12 +159,17 @@ impl PacketEntity {
|
||||||
parser_state: &'a ParserState,
|
parser_state: &'a ParserState,
|
||||||
) -> impl Iterator<Item = SendProp> + 'a {
|
) -> impl Iterator<Item = SendProp> + 'a {
|
||||||
if self.update_type == UpdateType::Enter {
|
if self.update_type == UpdateType::Enter {
|
||||||
Either::Left(
|
let mut found_props = HashSet::<SendPropIdentifier>::new();
|
||||||
self.get_baseline_props(parser_state)
|
let props = self.props.iter().cloned();
|
||||||
.into_owned()
|
let baseline_props = self
|
||||||
.into_iter()
|
.get_baseline_props(parser_state)
|
||||||
.chain(self.props.iter().cloned()),
|
.into_owned()
|
||||||
)
|
.into_iter();
|
||||||
|
Either::Left(props.chain(baseline_props).filter(move |prop| {
|
||||||
|
let found = found_props.contains(&prop.identifier);
|
||||||
|
found_props.insert(prop.identifier);
|
||||||
|
!found
|
||||||
|
}))
|
||||||
} else {
|
} else {
|
||||||
Either::Right(self.props.iter().cloned())
|
Either::Right(self.props.iter().cloned())
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue