1
0
Fork 0
mirror of https://github.com/alacritty/alacritty.git synced 2024-11-18 13:55:23 -05:00

Remove fs::read_to_string reimplementations

After two previous PRs already removed some instances of
reimplementations of the `fs::read_to_string` functionality, this
removes the last remaining occurence and with it all instances of
`File::open`. So this should remove them all for good.
This commit is contained in:
Christian Duerr 2020-03-26 14:56:41 +00:00 committed by GitHub
parent 06c07d3c75
commit fde2424b39
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 20 deletions

View file

@ -2663,8 +2663,7 @@ mod benches {
extern crate serde_json as json;
extern crate test;
use std::fs::File;
use std::io::Read;
use std::fs;
use std::mem;
use std::path::Path;
@ -2681,16 +2680,6 @@ mod benches {
fn send_event(&self, _event: Event) {}
}
fn read_string<P>(path: P) -> String
where
P: AsRef<Path>,
{
let mut res = String::new();
File::open(path.as_ref()).unwrap().read_to_string(&mut res).unwrap();
res
}
/// Benchmark for the renderable cells iterator
///
/// The renderable cells iterator yields cells that require work to be
@ -2703,14 +2692,16 @@ mod benches {
#[bench]
fn render_iter(b: &mut test::Bencher) {
// Need some realistic grid state; using one of the ref files.
let serialized_grid = read_string(concat!(
let serialized_grid = fs::read_to_string(concat!(
env!("CARGO_MANIFEST_DIR"),
"/tests/ref/vim_large_window_scroll/grid.json"
));
let serialized_size = read_string(concat!(
))
.unwrap();
let serialized_size = fs::read_to_string(concat!(
env!("CARGO_MANIFEST_DIR"),
"/tests/ref/vim_large_window_scroll/size.json"
));
))
.unwrap();
let mut grid: Grid<Cell> = json::from_str(&serialized_grid).unwrap();
let size: SizeInfo = json::from_str(&serialized_size).unwrap();

View file

@ -1,7 +1,7 @@
use serde::Deserialize;
use serde_json as json;
use std::fs::{read_to_string, File};
use std::fs::{self, File};
use std::io::{self, Read};
use std::path::Path;
@ -87,9 +87,9 @@ impl EventListener for Mock {
fn ref_test(dir: &Path) {
let recording = read_u8(dir.join("alacritty.recording"));
let serialized_size = read_to_string(dir.join("size.json")).unwrap();
let serialized_grid = read_to_string(dir.join("grid.json")).unwrap();
let serialized_cfg = read_to_string(dir.join("config.json")).unwrap();
let serialized_size = fs::read_to_string(dir.join("size.json")).unwrap();
let serialized_grid = fs::read_to_string(dir.join("grid.json")).unwrap();
let serialized_cfg = fs::read_to_string(dir.join("config.json")).unwrap();
let size: SizeInfo = json::from_str(&serialized_size).unwrap();
let grid: Grid<Cell> = json::from_str(&serialized_grid).unwrap();