mirror of
https://github.com/natsukagami/youmubot.git
synced 2025-04-19 08:48:54 +00:00
Parallelize list_pages beatmap name fetching
This commit is contained in:
parent
1c3b6a7cb2
commit
85e553673e
1 changed files with 2 additions and 1 deletions
|
@ -3,6 +3,7 @@ use crate::{
|
||||||
request::{BeatmapRequestKind, UserID},
|
request::{BeatmapRequestKind, UserID},
|
||||||
Client as OsuHttpClient,
|
Client as OsuHttpClient,
|
||||||
};
|
};
|
||||||
|
use rayon::prelude::*;
|
||||||
use serenity::{
|
use serenity::{
|
||||||
framework::standard::{
|
framework::standard::{
|
||||||
macros::{command, group},
|
macros::{command, group},
|
||||||
|
@ -242,7 +243,7 @@ fn list_plays(plays: &[Score], mode: Mode, ctx: Context, m: &Message) -> Command
|
||||||
let plays = &plays[start..end];
|
let plays = &plays[start..end];
|
||||||
let beatmaps = {
|
let beatmaps = {
|
||||||
let b = &mut beatmaps[start..end];
|
let b = &mut beatmaps[start..end];
|
||||||
b.iter_mut().enumerate().map(
|
b.par_iter_mut().enumerate().map(
|
||||||
|(i, v)| v.get_or_insert_with(
|
|(i, v)| v.get_or_insert_with(
|
||||||
|| osu.beatmaps(BeatmapRequestKind::Beatmap(plays[i].beatmap_id), |f| f)
|
|| osu.beatmaps(BeatmapRequestKind::Beatmap(plays[i].beatmap_id), |f| f)
|
||||||
.ok()
|
.ok()
|
||||||
|
|
Loading…
Add table
Reference in a new issue