Skip to content

Commit 06ccd70

Browse files
Use a superpub field in MapsEntry
This may eliminate some of the overhead of a getter. Also use a slightly more modern code style.
1 parent e48b001 commit 06ccd70

File tree

2 files changed

+4
-10
lines changed

2 files changed

+4
-10
lines changed

src/symbolize/gimli/libs_dl_iterate_phdr.rs

+3-4
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,9 @@ pub(super) fn native_libraries() -> Vec<Library> {
2020
fn infer_current_exe(base_addr: usize) -> OsString {
2121
if let Ok(entries) = super::parse_running_mmaps::parse_maps() {
2222
let opt_path = entries
23-
.iter()
24-
.find(|e| e.ip_matches(base_addr) && e.pathname().len() > 0)
25-
.map(|e| e.pathname())
26-
.cloned();
23+
.into_iter()
24+
.find(|e| e.ip_matches(base_addr) && !e.pathname.is_empty())
25+
.map(|e| e.pathname);
2726
if let Some(path) = opt_path {
2827
return path;
2928
}

src/symbolize/gimli/parse_running_mmaps_unix.rs

+1-6
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ pub(super) struct MapsEntry {
5050
/// in general the pathname may be ambiguous. (I.e. you cannot tell if the
5151
/// denoted filename actually ended with the text "(deleted)", or if that
5252
/// was added by the maps rendering.
53-
pathname: OsString,
53+
pub(super) pathname: OsString,
5454
}
5555

5656
pub(super) fn parse_maps() -> Result<Vec<MapsEntry>, &'static str> {
@@ -70,11 +70,6 @@ pub(super) fn parse_maps() -> Result<Vec<MapsEntry>, &'static str> {
7070
}
7171

7272
impl MapsEntry {
73-
#[inline]
74-
pub(super) fn pathname(&self) -> &OsString {
75-
&self.pathname
76-
}
77-
7873
#[inline]
7974
pub(super) fn ip_matches(&self, ip: usize) -> bool {
8075
self.address.0 <= ip && ip < self.address.1

0 commit comments

Comments
 (0)