@@ -12,6 +12,7 @@ use errors::DiagnosticBuilder;
12
12
use rustc_data_structures:: stable_hasher:: { HashStable , StableHasher } ;
13
13
use rustc_data_structures:: fx:: { FxHashMap , FxHashSet } ;
14
14
use rustc_data_structures:: indexed_vec:: { Idx , IndexVec } ;
15
+ use rustc_data_structures:: small_vec:: SmallVec ;
15
16
use rustc_data_structures:: sync:: { Lrc , RwLock , ReadGuard , Lock } ;
16
17
use std:: env;
17
18
use std:: hash:: Hash ;
@@ -132,7 +133,7 @@ impl DepGraph {
132
133
let mut edges = Vec :: new ( ) ;
133
134
for ( index, edge_targets) in current_dep_graph. edges . iter_enumerated ( ) {
134
135
let from = current_dep_graph. nodes [ index] ;
135
- for & edge_target in edge_targets {
136
+ for & edge_target in edge_targets. iter ( ) {
136
137
let to = current_dep_graph. nodes [ edge_target] ;
137
138
edges. push ( ( from, to) ) ;
138
139
}
@@ -210,7 +211,7 @@ impl DepGraph {
210
211
self . with_task_impl ( key, cx, arg, false , task,
211
212
|key| OpenTask :: Regular ( Lock :: new ( RegularOpenTask {
212
213
node : key,
213
- reads : Vec :: new ( ) ,
214
+ reads : SmallVec :: new ( ) ,
214
215
read_set : FxHashSet ( ) ,
215
216
} ) ) ,
216
217
|data, key, task| data. borrow_mut ( ) . complete_task ( key, task) )
@@ -231,7 +232,7 @@ impl DepGraph {
231
232
232
233
self . with_task_impl ( key, cx, input, true , identity_fn,
233
234
|_| OpenTask :: Ignore ,
234
- |data, key, _| data. borrow_mut ( ) . alloc_node ( key, Vec :: new ( ) ) )
235
+ |data, key, _| data. borrow_mut ( ) . alloc_node ( key, SmallVec :: new ( ) ) )
235
236
}
236
237
237
238
fn with_task_impl < ' gcx , C , A , R > (
@@ -354,7 +355,7 @@ impl DepGraph {
354
355
if let Some ( ref data) = self . data {
355
356
let ( result, open_task) = ty:: tls:: with_context ( |icx| {
356
357
let task = OpenTask :: Anon ( Lock :: new ( AnonOpenTask {
357
- reads : Vec :: new ( ) ,
358
+ reads : SmallVec :: new ( ) ,
358
359
read_set : FxHashSet ( ) ,
359
360
} ) ) ;
360
361
@@ -614,7 +615,7 @@ impl DepGraph {
614
615
615
616
debug_assert ! ( data. colors. borrow( ) . get( prev_dep_node_index) . is_none( ) ) ;
616
617
617
- let mut current_deps = Vec :: new ( ) ;
618
+ let mut current_deps = SmallVec :: new ( ) ;
618
619
619
620
for & dep_dep_node_index in prev_deps {
620
621
let dep_dep_node_color = data. colors . borrow ( ) . get ( dep_dep_node_index) ;
@@ -911,7 +912,7 @@ pub enum WorkProductFileKind {
911
912
912
913
pub ( super ) struct CurrentDepGraph {
913
914
nodes : IndexVec < DepNodeIndex , DepNode > ,
914
- edges : IndexVec < DepNodeIndex , Vec < DepNodeIndex > > ,
915
+ edges : IndexVec < DepNodeIndex , SmallVec < [ DepNodeIndex ; 8 ] > > ,
915
916
node_to_node_index : FxHashMap < DepNode , DepNodeIndex > ,
916
917
forbidden_edge : Option < EdgeFilter > ,
917
918
@@ -1049,7 +1050,7 @@ impl CurrentDepGraph {
1049
1050
} = task {
1050
1051
debug_assert_eq ! ( node, key) ;
1051
1052
let krate_idx = self . node_to_node_index [ & DepNode :: new_no_params ( DepKind :: Krate ) ] ;
1052
- self . alloc_node ( node, vec ! [ krate_idx] )
1053
+ self . alloc_node ( node, SmallVec :: one ( krate_idx) )
1053
1054
} else {
1054
1055
bug ! ( "complete_eval_always_task() - Expected eval always task to be popped" ) ;
1055
1056
}
@@ -1095,7 +1096,7 @@ impl CurrentDepGraph {
1095
1096
1096
1097
fn alloc_node ( & mut self ,
1097
1098
dep_node : DepNode ,
1098
- edges : Vec < DepNodeIndex > )
1099
+ edges : SmallVec < [ DepNodeIndex ; 8 ] > )
1099
1100
-> DepNodeIndex {
1100
1101
debug_assert_eq ! ( self . edges. len( ) , self . nodes. len( ) ) ;
1101
1102
debug_assert_eq ! ( self . node_to_node_index. len( ) , self . nodes. len( ) ) ;
@@ -1110,12 +1111,12 @@ impl CurrentDepGraph {
1110
1111
1111
1112
pub struct RegularOpenTask {
1112
1113
node : DepNode ,
1113
- reads : Vec < DepNodeIndex > ,
1114
+ reads : SmallVec < [ DepNodeIndex ; 8 ] > ,
1114
1115
read_set : FxHashSet < DepNodeIndex > ,
1115
1116
}
1116
1117
1117
1118
pub struct AnonOpenTask {
1118
- reads : Vec < DepNodeIndex > ,
1119
+ reads : SmallVec < [ DepNodeIndex ; 8 ] > ,
1119
1120
read_set : FxHashSet < DepNodeIndex > ,
1120
1121
}
1121
1122
0 commit comments