@@ -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 ;
@@ -131,7 +132,7 @@ impl DepGraph {
131
132
let mut edges = Vec :: new ( ) ;
132
133
for ( index, edge_targets) in current_dep_graph. edges . iter_enumerated ( ) {
133
134
let from = current_dep_graph. nodes [ index] ;
134
- for & edge_target in edge_targets {
135
+ for & edge_target in edge_targets. iter ( ) {
135
136
let to = current_dep_graph. nodes [ edge_target] ;
136
137
edges. push ( ( from, to) ) ;
137
138
}
@@ -209,7 +210,7 @@ impl DepGraph {
209
210
self . with_task_impl ( key, cx, arg, false , task,
210
211
|key| OpenTask :: Regular ( Lock :: new ( RegularOpenTask {
211
212
node : key,
212
- reads : Vec :: new ( ) ,
213
+ reads : SmallVec :: new ( ) ,
213
214
read_set : FxHashSet ( ) ,
214
215
} ) ) ,
215
216
|data, key, task| data. borrow_mut ( ) . complete_task ( key, task) )
@@ -230,7 +231,7 @@ impl DepGraph {
230
231
231
232
self . with_task_impl ( key, cx, input, true , identity_fn,
232
233
|_| OpenTask :: Ignore ,
233
- |data, key, _| data. borrow_mut ( ) . alloc_node ( key, Vec :: new ( ) ) )
234
+ |data, key, _| data. borrow_mut ( ) . alloc_node ( key, SmallVec :: new ( ) ) )
234
235
}
235
236
236
237
fn with_task_impl < ' gcx , C , A , R > (
@@ -353,7 +354,7 @@ impl DepGraph {
353
354
if let Some ( ref data) = self . data {
354
355
let ( result, open_task) = ty:: tls:: with_context ( |icx| {
355
356
let task = OpenTask :: Anon ( Lock :: new ( AnonOpenTask {
356
- reads : Vec :: new ( ) ,
357
+ reads : SmallVec :: new ( ) ,
357
358
read_set : FxHashSet ( ) ,
358
359
} ) ) ;
359
360
@@ -626,7 +627,7 @@ impl DepGraph {
626
627
627
628
debug_assert ! ( data. colors. borrow( ) . get( prev_dep_node_index) . is_none( ) ) ;
628
629
629
- let mut current_deps = Vec :: new ( ) ;
630
+ let mut current_deps = SmallVec :: new ( ) ;
630
631
631
632
for & dep_dep_node_index in prev_deps {
632
633
let dep_dep_node_color = data. colors . borrow ( ) . get ( dep_dep_node_index) ;
@@ -923,7 +924,7 @@ pub enum WorkProductFileKind {
923
924
924
925
pub ( super ) struct CurrentDepGraph {
925
926
nodes : IndexVec < DepNodeIndex , DepNode > ,
926
- edges : IndexVec < DepNodeIndex , Vec < DepNodeIndex > > ,
927
+ edges : IndexVec < DepNodeIndex , SmallVec < [ DepNodeIndex ; 8 ] > > ,
927
928
node_to_node_index : FxHashMap < DepNode , DepNodeIndex > ,
928
929
forbidden_edge : Option < EdgeFilter > ,
929
930
@@ -1061,7 +1062,7 @@ impl CurrentDepGraph {
1061
1062
} = task {
1062
1063
debug_assert_eq ! ( node, key) ;
1063
1064
let krate_idx = self . node_to_node_index [ & DepNode :: new_no_params ( DepKind :: Krate ) ] ;
1064
- self . alloc_node ( node, vec ! [ krate_idx] )
1065
+ self . alloc_node ( node, SmallVec :: one ( krate_idx) )
1065
1066
} else {
1066
1067
bug ! ( "complete_eval_always_task() - Expected eval always task to be popped" ) ;
1067
1068
}
@@ -1107,7 +1108,7 @@ impl CurrentDepGraph {
1107
1108
1108
1109
fn alloc_node ( & mut self ,
1109
1110
dep_node : DepNode ,
1110
- edges : Vec < DepNodeIndex > )
1111
+ edges : SmallVec < [ DepNodeIndex ; 8 ] > )
1111
1112
-> DepNodeIndex {
1112
1113
debug_assert_eq ! ( self . edges. len( ) , self . nodes. len( ) ) ;
1113
1114
debug_assert_eq ! ( self . node_to_node_index. len( ) , self . nodes. len( ) ) ;
@@ -1122,12 +1123,12 @@ impl CurrentDepGraph {
1122
1123
1123
1124
pub struct RegularOpenTask {
1124
1125
node : DepNode ,
1125
- reads : Vec < DepNodeIndex > ,
1126
+ reads : SmallVec < [ DepNodeIndex ; 8 ] > ,
1126
1127
read_set : FxHashSet < DepNodeIndex > ,
1127
1128
}
1128
1129
1129
1130
pub struct AnonOpenTask {
1130
- reads : Vec < DepNodeIndex > ,
1131
+ reads : SmallVec < [ DepNodeIndex ; 8 ] > ,
1131
1132
read_set : FxHashSet < DepNodeIndex > ,
1132
1133
}
1133
1134
0 commit comments