Skip to content

Commit cc0cdbb

Browse files
committed
switch to pure Read rather than BufRead based implementation, to save a bit on code size.
ls -sk before: 1052 target/release/libbacktrace.rlib ls -sk after: 1044 target/release/libbacktrace.rlib
1 parent b125d9c commit cc0cdbb

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

src/symbolize/gimli/parse_running_mmaps_unix.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
// general purpose, but it hasn't been tested elsewhere.
44

55
use super::mystd::fs::File;
6-
use super::mystd::io::{BufRead, BufReader};
6+
use super::mystd::io::Read;
77
use super::mystd::str::FromStr;
8-
use super::{OsString, Vec};
8+
use super::{OsString, String, Vec};
99

1010
#[derive(PartialEq, Eq, Debug)]
1111
pub(super) struct MapsEntry {
@@ -55,11 +55,11 @@ pub(super) struct MapsEntry {
5555

5656
pub(super) fn parse_maps() -> Result<Vec<MapsEntry>, &'static str> {
5757
let mut v = Vec::new();
58-
let proc_self_maps =
58+
let mut proc_self_maps =
5959
File::open("/proc/self/maps").map_err(|_| "Couldn't open /proc/self/maps")?;
60-
let proc_self_maps = BufReader::new(proc_self_maps);
61-
for line in proc_self_maps.lines() {
62-
let line = line.map_err(|_io_error| "Couldn't read line from /proc/self/maps")?;
60+
let mut buf = String::new();
61+
let _bytes_read = proc_self_maps.read_to_string(&mut buf).map_err(|_| "Couldn't read /proc/self/maps")?;
62+
for line in buf.lines() {
6363
v.push(line.parse()?);
6464
}
6565

0 commit comments

Comments
 (0)