@@ -8,7 +8,7 @@ use rustc_index::vec::Idx;
88use std:: error:: Error ;
99use std:: fmt:: Debug ;
1010use std:: fs:: { self , File } ;
11- use std:: io:: Write ;
11+ use std:: io:: { BufWriter , Write } ;
1212use std:: path:: Path ;
1313
1414#[ derive( Copy , Clone , Debug ) ]
@@ -117,7 +117,7 @@ impl<'w> FactWriter<'w> {
117117 T : FactRow ,
118118 {
119119 let file = & self . dir . join ( file_name) ;
120- let mut file = File :: create ( file) ?;
120+ let mut file = BufWriter :: new ( File :: create ( file) ?) ;
121121 for row in rows {
122122 row. write ( & mut file, self . location_table ) ?;
123123 }
@@ -126,11 +126,19 @@ impl<'w> FactWriter<'w> {
126126}
127127
128128trait FactRow {
129- fn write ( & self , out : & mut File , location_table : & LocationTable ) -> Result < ( ) , Box < dyn Error > > ;
129+ fn write (
130+ & self ,
131+ out : & mut dyn Write ,
132+ location_table : & LocationTable ,
133+ ) -> Result < ( ) , Box < dyn Error > > ;
130134}
131135
132136impl FactRow for RegionVid {
133- fn write ( & self , out : & mut File , location_table : & LocationTable ) -> Result < ( ) , Box < dyn Error > > {
137+ fn write (
138+ & self ,
139+ out : & mut dyn Write ,
140+ location_table : & LocationTable ,
141+ ) -> Result < ( ) , Box < dyn Error > > {
134142 write_row ( out, location_table, & [ self ] )
135143 }
136144}
@@ -140,7 +148,11 @@ where
140148 A : FactCell ,
141149 B : FactCell ,
142150{
143- fn write ( & self , out : & mut File , location_table : & LocationTable ) -> Result < ( ) , Box < dyn Error > > {
151+ fn write (
152+ & self ,
153+ out : & mut dyn Write ,
154+ location_table : & LocationTable ,
155+ ) -> Result < ( ) , Box < dyn Error > > {
144156 write_row ( out, location_table, & [ & self . 0 , & self . 1 ] )
145157 }
146158}
@@ -151,7 +163,11 @@ where
151163 B : FactCell ,
152164 C : FactCell ,
153165{
154- fn write ( & self , out : & mut File , location_table : & LocationTable ) -> Result < ( ) , Box < dyn Error > > {
166+ fn write (
167+ & self ,
168+ out : & mut dyn Write ,
169+ location_table : & LocationTable ,
170+ ) -> Result < ( ) , Box < dyn Error > > {
155171 write_row ( out, location_table, & [ & self . 0 , & self . 1 , & self . 2 ] )
156172 }
157173}
@@ -163,7 +179,11 @@ where
163179 C : FactCell ,
164180 D : FactCell ,
165181{
166- fn write ( & self , out : & mut File , location_table : & LocationTable ) -> Result < ( ) , Box < dyn Error > > {
182+ fn write (
183+ & self ,
184+ out : & mut dyn Write ,
185+ location_table : & LocationTable ,
186+ ) -> Result < ( ) , Box < dyn Error > > {
167187 write_row ( out, location_table, & [ & self . 0 , & self . 1 , & self . 2 , & self . 3 ] )
168188 }
169189}
0 commit comments