Skip to content

Commit

Permalink
prevent unnecessary lock acquirement
Browse files Browse the repository at this point in the history
  • Loading branch information
B-2U committed Feb 25, 2024
1 parent dab3808 commit 14a4cfe
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions src/cmds/leaderboard.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,14 @@ async fn func_top(ctx: Context<'_>, region: Region, ship: Ship) -> Result<(), Er
}
};
// color patrons
lb_players.iter_mut().take(15).for_each(|p| {
if ctx.data().patron.read().check_player(&p.uid) {
p.color = "#e85a6b".to_string();
}
});
{
let patrons_rg = ctx.data().patron.read();
lb_players.iter_mut().take(15).for_each(|p| {
if patrons_rg.check_player(&p.uid) {
p.color = "#e85a6b".to_string();
}
})
};

// if user is in the leaderboard, set color and swap its index if needed
let truncate_len = if let Some((p_index, p)) =
Expand Down

0 comments on commit 14a4cfe

Please sign in to comment.