Clean up with_task
.
Currently it creates an `Option` and then does `map`/`unwrap_or` and `map_or_else` on it, which is hard to read. This commit simplifies things by moving more code into the two arms of the if/else.
This commit is contained in:
parent
458d4dae84
commit
207cec017f
@ -354,24 +354,20 @@ pub fn with_task<Ctxt: HasDepContext<DepKind = K>, A: Debug, R>(
|
|||||||
- dep-node: {key:?}"
|
- dep-node: {key:?}"
|
||||||
);
|
);
|
||||||
|
|
||||||
let task_deps = if cx.dep_context().is_eval_always(key.kind) {
|
let with_deps = |task_deps| K::with_deps(task_deps, || task(cx, arg));
|
||||||
None
|
let (result, edges) = if cx.dep_context().is_eval_always(key.kind) {
|
||||||
|
(with_deps(TaskDepsRef::EvalAlways), smallvec![])
|
||||||
} else {
|
} else {
|
||||||
Some(Lock::new(TaskDeps {
|
let task_deps = Lock::new(TaskDeps {
|
||||||
#[cfg(debug_assertions)]
|
#[cfg(debug_assertions)]
|
||||||
node: Some(key),
|
node: Some(key),
|
||||||
reads: SmallVec::new(),
|
reads: SmallVec::new(),
|
||||||
read_set: Default::default(),
|
read_set: Default::default(),
|
||||||
phantom_data: PhantomData,
|
phantom_data: PhantomData,
|
||||||
}))
|
});
|
||||||
|
(with_deps(TaskDepsRef::Allow(&task_deps)), task_deps.into_inner().reads)
|
||||||
};
|
};
|
||||||
|
|
||||||
let task_deps_ref =
|
|
||||||
task_deps.as_ref().map(TaskDepsRef::Allow).unwrap_or(TaskDepsRef::EvalAlways);
|
|
||||||
|
|
||||||
let result = K::with_deps(task_deps_ref, || task(cx, arg));
|
|
||||||
let edges = task_deps.map_or_else(|| smallvec![], |lock| lock.into_inner().reads);
|
|
||||||
|
|
||||||
let dcx = cx.dep_context();
|
let dcx = cx.dep_context();
|
||||||
let hashing_timer = dcx.profiler().incr_result_hashing();
|
let hashing_timer = dcx.profiler().incr_result_hashing();
|
||||||
let current_fingerprint =
|
let current_fingerprint =
|
||||||
|
Loading…
Reference in New Issue
Block a user