mirror of
https://codeberg.org/icewind/tf-log-parser.git
synced 2026-06-03 18:24:09 +02:00
faster SubjectId
This commit is contained in:
parent
a9302218cb
commit
a6ecc8e140
2 changed files with 15 additions and 5 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
|
@ -1,2 +1,3 @@
|
||||||
/target
|
/target
|
||||||
Cargo.lock
|
Cargo.lock
|
||||||
|
callgrind.*
|
||||||
|
|
@ -182,11 +182,20 @@ impl TryFrom<&RawSubject<'_>> for SubjectId {
|
||||||
|
|
||||||
fn try_from(raw: &RawSubject) -> Result<Self, Self::Error> {
|
fn try_from(raw: &RawSubject) -> Result<Self, Self::Error> {
|
||||||
Ok(match raw {
|
Ok(match raw {
|
||||||
RawSubject::Player { steam_id, .. } => SubjectId::Player(
|
RawSubject::Player { steam_id, .. } => {
|
||||||
SteamID::from_steam3(steam_id)
|
if let Some(raw_account_id) = steam_id
|
||||||
.map_err(|_| SubjectError::InvalidSteamId)?
|
.strip_prefix("[U:1:")
|
||||||
.account_id(),
|
.and_then(|s| s.strip_suffix(']'))
|
||||||
),
|
{
|
||||||
|
SubjectId::Player(
|
||||||
|
raw_account_id
|
||||||
|
.parse()
|
||||||
|
.map_err(|_| SubjectError::InvalidSteamId)?,
|
||||||
|
)
|
||||||
|
} else {
|
||||||
|
return Err(SubjectError::InvalidSteamId);
|
||||||
|
}
|
||||||
|
}
|
||||||
RawSubject::Team(team) => {
|
RawSubject::Team(team) => {
|
||||||
SubjectId::Team(team.parse().map_err(|_| SubjectError::InvalidTeam)?)
|
SubjectId::Team(team.parse().map_err(|_| SubjectError::InvalidTeam)?)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue