@@ -1672,48 +1672,45 @@ impl<B: BackingStorage> TurboTasksBackendInner<B> {
16721672
16731673 if self . should_track_dependencies ( ) {
16741674 // Make all dependencies outdated
1675- enum Dep {
1676- CurrentCell ( CellRef ) ,
1677- CurrentOutput ( TaskId ) ,
1678- OutdatedCell ( CellRef ) ,
1679- OutdatedOutput ( TaskId ) ,
1675+ let outdated_cell_dependencies_to_add =
1676+ iter_many ! ( task, CellDependency { target } => target)
1677+ . collect :: < SmallVec < [ _ ; 8 ] > > ( ) ;
1678+ let outdated_cell_dependencies_to_remove =
1679+ iter_many ! ( task, OutdatedCellDependency { target } => target)
1680+ . filter ( |& target| {
1681+ !task. has_key ( & CachedDataItemKey :: CellDependency { target } )
1682+ } )
1683+ . collect :: < SmallVec < [ _ ; 8 ] > > ( ) ;
1684+ task. extend (
1685+ CachedDataItemType :: OutdatedCellDependency ,
1686+ outdated_cell_dependencies_to_add
1687+ . into_iter ( )
1688+ . map ( |target| CachedDataItem :: OutdatedCellDependency { target, value : ( ) } ) ,
1689+ ) ;
1690+ for target in outdated_cell_dependencies_to_remove {
1691+ task. remove ( & CachedDataItemKey :: OutdatedCellDependency { target } ) ;
16801692 }
1681- let dependencies = iter_many ! ( task, CellDependency { target } => Dep :: CurrentCell ( target) )
1682- . chain ( iter_many ! ( task, OutputDependency { target } => Dep :: CurrentOutput ( target) ) )
1683- . chain ( iter_many ! ( task, OutdatedCellDependency { target } => Dep :: OutdatedCell ( target) ) )
1684- . chain ( iter_many ! ( task, OutdatedOutputDependency { target } => Dep :: OutdatedOutput ( target) ) )
1685- . collect :: < Vec < _ > > ( ) ;
1686- for dep in dependencies {
1687- match dep {
1688- Dep :: CurrentCell ( cell) => {
1689- let _ = task. add ( CachedDataItem :: OutdatedCellDependency {
1690- target : cell,
1691- value : ( ) ,
1692- } ) ;
1693- }
1694- Dep :: CurrentOutput ( output) => {
1695- let _ = task. add ( CachedDataItem :: OutdatedOutputDependency {
1696- target : output,
1697- value : ( ) ,
1698- } ) ;
1699- }
1700- Dep :: OutdatedCell ( cell) => {
1701- if !task. has_key ( & CachedDataItemKey :: CellDependency { target : cell } ) {
1702- task. remove ( & CachedDataItemKey :: OutdatedCellDependency {
1703- target : cell,
1704- } ) ;
1705- }
1706- }
1707- Dep :: OutdatedOutput ( output) => {
1708- if !task
1709- . has_key ( & CachedDataItemKey :: OutputDependency { target : output } )
1710- {
1711- task. remove ( & CachedDataItemKey :: OutdatedOutputDependency {
1712- target : output,
1713- } ) ;
1714- }
1715- }
1716- }
1693+
1694+ let outdated_output_dependencies_to_add =
1695+ iter_many ! ( task, OutputDependency { target } => target)
1696+ . collect :: < SmallVec < [ _ ; 8 ] > > ( ) ;
1697+ let outdated_output_dependencies_to_remove =
1698+ iter_many ! ( task, OutdatedOutputDependency { target } => target)
1699+ . filter ( |& target| {
1700+ !task. has_key ( & CachedDataItemKey :: OutputDependency { target } )
1701+ } )
1702+ . collect :: < SmallVec < [ _ ; 8 ] > > ( ) ;
1703+ task. extend (
1704+ CachedDataItemType :: OutdatedOutputDependency ,
1705+ outdated_output_dependencies_to_add
1706+ . into_iter ( )
1707+ . map ( |target| CachedDataItem :: OutdatedOutputDependency {
1708+ target,
1709+ value : ( ) ,
1710+ } ) ,
1711+ ) ;
1712+ for target in outdated_output_dependencies_to_remove {
1713+ task. remove ( & CachedDataItemKey :: OutdatedOutputDependency { target } ) ;
17171714 }
17181715 }
17191716 }
@@ -1949,21 +1946,27 @@ impl<B: BackingStorage> TurboTasksBackendInner<B> {
19491946 let old_counters: FxHashMap < _ , _ > =
19501947 get_many ! ( task, CellTypeMaxIndex { cell_type } max_index => ( cell_type, * max_index) ) ;
19511948 let mut counters_to_remove = old_counters. clone ( ) ;
1952- for ( & cell_type, & max_index) in cell_counters. iter ( ) {
1953- if let Some ( old_max_index) = counters_to_remove. remove ( & cell_type) {
1954- if old_max_index != max_index {
1955- task. insert ( CachedDataItem :: CellTypeMaxIndex {
1949+
1950+ task. extend (
1951+ CachedDataItemType :: CellTypeMaxIndex ,
1952+ cell_counters. iter ( ) . filter_map ( |( & cell_type, & max_index) | {
1953+ if let Some ( old_max_index) = counters_to_remove. remove ( & cell_type) {
1954+ if old_max_index != max_index {
1955+ Some ( CachedDataItem :: CellTypeMaxIndex {
1956+ cell_type,
1957+ value : max_index,
1958+ } )
1959+ } else {
1960+ None
1961+ }
1962+ } else {
1963+ Some ( CachedDataItem :: CellTypeMaxIndex {
19561964 cell_type,
19571965 value : max_index,
1958- } ) ;
1966+ } )
19591967 }
1960- } else {
1961- task. add_new ( CachedDataItem :: CellTypeMaxIndex {
1962- cell_type,
1963- value : max_index,
1964- } ) ;
1965- }
1966- }
1968+ } ) ,
1969+ ) ;
19671970 for ( cell_type, _) in counters_to_remove {
19681971 task. remove ( & CachedDataItemKey :: CellTypeMaxIndex { cell_type } ) ;
19691972 }
0 commit comments