mirror of
https://github.com/roc-lang/roc.git
synced 2024-11-11 05:34:11 +03:00
Avoid cloning on the main thread
This commit is contained in:
parent
11e2f998fc
commit
f79ead7f02
@ -902,16 +902,18 @@ fn spawn_solve_module(
|
||||
);
|
||||
}
|
||||
|
||||
let mut aliases = Vec::with_capacity(stdlib.aliases.len());
|
||||
|
||||
// We need to clone these to send them to another thread, but
|
||||
// all the thread does is iterate over them, so use a Vec instead of a Map.
|
||||
for (symbol, alias) in stdlib.aliases.iter() {
|
||||
aliases.push((*symbol, alias.clone()));
|
||||
}
|
||||
// We can't pass the reference to stdlib to the thread, but we can pass mode.
|
||||
let mode = stdlib.mode;
|
||||
|
||||
// Start solving this module in the background.
|
||||
spawn_blocking(move || {
|
||||
// Rebuild the aliases in this thread, so we don't have to clone all of
|
||||
// stdlib.aliases on the main thread.
|
||||
let aliases = match mode {
|
||||
Mode::Standard => roc_builtins::std::aliases(),
|
||||
Mode::Uniqueness => roc_builtins::unique::aliases(),
|
||||
};
|
||||
|
||||
// Finish constraining the module by wrapping the existing Constraint
|
||||
// in the ones we just computed. We can do this off the main thread.
|
||||
// TODO what to do with the introduced rigids?
|
||||
|
Loading…
Reference in New Issue
Block a user