@@ -52,60 +52,63 @@ impl UpdateCellOperation {
52
52
task. has_key ( & CachedDataItemKey :: Stateful { } ) ) ;
53
53
54
54
if should_invalidate {
55
- // Slow path: We need to invalidate tasks depending on this cell.
56
- // To avoid a race condition, we need to remove the old content first,
57
- // then invalidate dependent tasks and only then update the cell content.
58
-
59
- let old_content = task. remove ( & CachedDataItemKey :: CellData { cell } ) ;
60
-
61
- let dependent_tasks = get_many ! (
55
+ let dependent_tasks: SmallVec < [ TaskId ; 4 ] > = get_many ! (
62
56
task,
63
57
CellDependent { cell: dependent_cell, task }
64
58
if dependent_cell == cell
65
59
=> task
66
60
) ;
67
61
68
- drop ( task) ;
69
- drop ( old_content) ;
70
-
71
- let content = if let CellContent ( Some ( new_content) ) = content {
72
- Some ( new_content. into_typed ( cell. type_id ) )
73
- } else {
74
- None
75
- } ;
76
-
77
- UpdateCellOperation :: InvalidateWhenCellDependency {
78
- cell_ref : CellRef {
79
- task : task_id,
80
- cell,
81
- } ,
82
- dependent_tasks,
83
- content,
84
- queue : AggregationUpdateQueue :: new ( ) ,
62
+ if !dependent_tasks. is_empty ( ) {
63
+ // Slow path: We need to invalidate tasks depending on this cell.
64
+ // To avoid a race condition, we need to remove the old content first,
65
+ // then invalidate dependent tasks and only then update the cell content.
66
+
67
+ let old_content = task. remove ( & CachedDataItemKey :: CellData { cell } ) ;
68
+
69
+ drop ( task) ;
70
+ drop ( old_content) ;
71
+
72
+ let content = if let CellContent ( Some ( new_content) ) = content {
73
+ Some ( new_content. into_typed ( cell. type_id ) )
74
+ } else {
75
+ None
76
+ } ;
77
+
78
+ UpdateCellOperation :: InvalidateWhenCellDependency {
79
+ cell_ref : CellRef {
80
+ task : task_id,
81
+ cell,
82
+ } ,
83
+ dependent_tasks,
84
+ content,
85
+ queue : AggregationUpdateQueue :: new ( ) ,
86
+ }
87
+ . execute ( & mut ctx) ;
88
+ return ;
85
89
}
86
- . execute ( & mut ctx) ;
90
+ }
91
+
92
+ // Fast path: We don't need to invalidate anything.
93
+ // So we can just update the cell content.
94
+
95
+ let old_content = if let CellContent ( Some ( new_content) ) = content {
96
+ let new_content = new_content. into_typed ( cell. type_id ) ;
97
+ task. insert ( CachedDataItem :: CellData {
98
+ cell,
99
+ value : new_content,
100
+ } )
87
101
} else {
88
- // Fast path: We don't need to invalidate anything.
89
- // So we can just update the cell content.
90
-
91
- let old_content = if let CellContent ( Some ( new_content) ) = content {
92
- let new_content = new_content. into_typed ( cell. type_id ) ;
93
- task. insert ( CachedDataItem :: CellData {
94
- cell,
95
- value : new_content,
96
- } )
97
- } else {
98
- task. remove ( & CachedDataItemKey :: CellData { cell } )
99
- } ;
100
-
101
- let in_progress_cell = remove ! ( task, InProgressCell { cell } ) ;
102
-
103
- drop ( task) ;
104
- drop ( old_content) ;
105
-
106
- if let Some ( in_progress) = in_progress_cell {
107
- in_progress. event . notify ( usize:: MAX ) ;
108
- }
102
+ task. remove ( & CachedDataItemKey :: CellData { cell } )
103
+ } ;
104
+
105
+ let in_progress_cell = remove ! ( task, InProgressCell { cell } ) ;
106
+
107
+ drop ( task) ;
108
+ drop ( old_content) ;
109
+
110
+ if let Some ( in_progress) = in_progress_cell {
111
+ in_progress. event . notify ( usize:: MAX ) ;
109
112
}
110
113
}
111
114
}
0 commit comments