Skip to content

Commit

Permalink
Minor improvements (clippy, API)
Browse files Browse the repository at this point in the history
  • Loading branch information
bgw committed Jun 9, 2024
1 parent 144e0be commit a43455d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 8 deletions.
2 changes: 1 addition & 1 deletion crates/turbo-tasks-memory/src/memory_backend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -560,7 +560,7 @@ impl Backend for MemoryBackend {
.first()
.cloned()
.expect("No arguments for trait call");
let stats = Arc::clone(&stats);
let stats = Arc::clone(stats);
turbo_tasks.run_once(Box::pin(async move {
let function_id =
PersistentTaskType::resolve_trait_method(trait_type, name, this)
Expand Down
10 changes: 3 additions & 7 deletions crates/turbo-tasks-memory/src/task_statistics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,12 @@ pub struct TaskStatisticsApi {
}

impl TaskStatisticsApi {
pub fn enable(&self) {
pub fn enable(&self) -> &Arc<TaskStatistics> {
// ignore error: potentially already initialized, that's okay
let _ = self.inner.set(Arc::new(TaskStatistics {
inner: DashMap::new(),
}));
self.inner.get().unwrap()
}

pub fn is_enabled(&self) -> bool {
Expand Down Expand Up @@ -55,12 +56,7 @@ impl TaskStatistics {
task_function_id: FunctionId,
func: impl Fn(&mut TaskFunctionStatistics),
) {
func(
self.inner
.entry(task_function_id)
.or_insert(TaskFunctionStatistics::default())
.value_mut(),
)
func(self.inner.entry(task_function_id).or_default().value_mut())
}
}

Expand Down

0 comments on commit a43455d

Please sign in to comment.