Skip to content

Commit dae208d

Browse files
authored
Merge pull request #102 from rusty-sec/read_performance
improve Reading files performance
2 parents 23db8af + 0ea8217 commit dae208d

File tree

1 file changed

+4
-9
lines changed

1 file changed

+4
-9
lines changed

src/lua/parsing/files.rs

+4-9
Original file line numberDiff line numberDiff line change
@@ -12,18 +12,13 @@
1212
// either express or implied. See the License for the specific language governing permissions
1313
// and limitations under the License.
1414

15-
use log::{debug, error};
1615
use std::fs::File;
17-
use std::io::Read;
16+
use std::io::{BufReader,Read};
1817

1918
pub fn filename_to_string(s: &str) -> Result<String, std::io::Error> {
20-
let file = File::open(s);
21-
debug!("READING {:?}", s);
22-
if file.is_err() {
23-
error!("READING ERROR: {:?}", s);
24-
return Err(file.unwrap_err());
25-
}
19+
let file = File::open(s)?;
20+
let mut buf_reader = BufReader::new(file);
2621
let mut s = String::new();
27-
file.unwrap().read_to_string(&mut s)?;
22+
buf_reader.read_to_string(&mut s)?;
2823
Ok(s)
2924
}

0 commit comments

Comments
 (0)