Skip to content

Commit

Permalink
small thread optimisations
Browse files Browse the repository at this point in the history
  • Loading branch information
bananaturtlesandwich committed May 13, 2023
1 parent f131eeb commit d8e2627
Show file tree
Hide file tree
Showing 3 changed files with 282 additions and 253 deletions.
10 changes: 4 additions & 6 deletions src/writing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,12 +103,10 @@ pub fn write(data: Data, app: &crate::Rando) -> Result<(), Error> {
save(&mut spirit_hunter, &loc)?;
std::thread::scope(|thread| -> Result<(), Error> {
for thread in [
thread.spawn(|| -> Result<(), Error> { overworld::write(data.overworld, app, &pak) }),
thread.spawn(|| -> Result<(), Error> { cutscenes::write(data.cutscenes, app, &pak) }),
thread.spawn(|| -> Result<(), Error> {
savegames::write(data.savegames, data.shop_emotes, app, &pak)
}),
thread.spawn(|| -> Result<(), Error> { specific::write(data.cases, app, &pak) }),
thread.spawn(|| overworld::write(data.overworld, app, &pak)),
thread.spawn(|| cutscenes::write(data.cutscenes, app, &pak)),
thread.spawn(|| savegames::write(data.savegames, data.shop_emotes, app, &pak)),
thread.spawn(|| specific::write(data.cases, app, &pak)),
] {
thread.join().unwrap()?
}
Expand Down
2 changes: 1 addition & 1 deletion src/writing/cutscenes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ pub fn write(cutscenes: Vec<Check>, app: &crate::Rando, pak: &unpak::Pak) -> Res
std::thread::scope(|thread| -> Result<(), Error> {
let mut threads = Vec::with_capacity(cutscenes.len());
for Check { context, drop, .. } in cutscenes {
threads.push(thread.spawn(move || -> Result<(), Error> {
threads.push(thread.spawn(move || {
let Context::Cutscene(cutscene) = context else {
return Err(Error::Assumption);
};
Expand Down
Loading

0 comments on commit d8e2627

Please sign in to comment.