Skip to content

Commit 43e813c

Browse files
committed
Replace TaskDeps::default() with TaskDeps::new().
There are only two places that create a `TaskDeps`. One constructs it manually, the other uses `default`. It's weird that `default()` uses a capacity of 128. This commit just gets rid of `default` and introduces `new` so that both construction sites can be equivalent.
1 parent 38d7e8b commit 43e813c

File tree

1 file changed

+16
-12
lines changed
  • compiler/rustc_query_system/src/dep_graph

1 file changed

+16
-12
lines changed

compiler/rustc_query_system/src/dep_graph/graph.rs

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -349,13 +349,11 @@ impl<D: Deps> DepGraphData<D> {
349349
let (result, edges) = if cx.dep_context().is_eval_always(key.kind) {
350350
(with_deps(TaskDepsRef::EvalAlways), EdgesVec::new())
351351
} else {
352-
let task_deps = Lock::new(TaskDeps {
352+
let task_deps = Lock::new(TaskDeps::new(
353353
#[cfg(debug_assertions)]
354-
node: Some(key),
355-
reads: EdgesVec::new(),
356-
read_set: Default::default(),
357-
phantom_data: PhantomData,
358-
});
354+
Some(key),
355+
0,
356+
));
359357
(with_deps(TaskDepsRef::Allow(&task_deps)), task_deps.into_inner().reads)
360358
};
361359

@@ -387,7 +385,11 @@ impl<D: Deps> DepGraphData<D> {
387385
{
388386
debug_assert!(!cx.is_eval_always(dep_kind));
389387

390-
let task_deps = Lock::new(TaskDeps::default());
388+
let task_deps = Lock::new(TaskDeps::new(
389+
#[cfg(debug_assertions)]
390+
None,
391+
128,
392+
));
391393
let result = D::with_deps(TaskDepsRef::Allow(&task_deps), op);
392394
let task_deps = task_deps.into_inner();
393395
let reads = task_deps.reads;
@@ -1307,17 +1309,19 @@ pub struct TaskDeps {
13071309
phantom_data: PhantomData<DepNode>,
13081310
}
13091311

1310-
impl Default for TaskDeps {
1311-
fn default() -> Self {
1312-
Self {
1312+
impl TaskDeps {
1313+
#[inline]
1314+
fn new(#[cfg(debug_assertions)] node: Option<DepNode>, read_set_capacity: usize) -> Self {
1315+
TaskDeps {
13131316
#[cfg(debug_assertions)]
1314-
node: None,
1317+
node,
13151318
reads: EdgesVec::new(),
1316-
read_set: FxHashSet::with_capacity_and_hasher(128, Default::default()),
1319+
read_set: FxHashSet::with_capacity_and_hasher(read_set_capacity, Default::default()),
13171320
phantom_data: PhantomData,
13181321
}
13191322
}
13201323
}
1324+
13211325
// A data structure that stores Option<DepNodeColor> values as a contiguous
13221326
// array, using one u32 per entry.
13231327
pub(super) struct DepNodeColorMap {

0 commit comments

Comments
 (0)