From 06ccd70da9f3367fce2842cab5cfa3212d0cbea5 Mon Sep 17 00:00:00 2001 From: Jubilee Young Date: Thu, 6 Jul 2023 17:58:51 -0700 Subject: [PATCH] Use a superpub field in MapsEntry This may eliminate some of the overhead of a getter. Also use a slightly more modern code style. --- src/symbolize/gimli/libs_dl_iterate_phdr.rs | 7 +++---- src/symbolize/gimli/parse_running_mmaps_unix.rs | 7 +------ 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/symbolize/gimli/libs_dl_iterate_phdr.rs b/src/symbolize/gimli/libs_dl_iterate_phdr.rs index 9f0304ce8..432e2f163 100644 --- a/src/symbolize/gimli/libs_dl_iterate_phdr.rs +++ b/src/symbolize/gimli/libs_dl_iterate_phdr.rs @@ -20,10 +20,9 @@ pub(super) fn native_libraries() -> Vec { fn infer_current_exe(base_addr: usize) -> OsString { if let Ok(entries) = super::parse_running_mmaps::parse_maps() { let opt_path = entries - .iter() - .find(|e| e.ip_matches(base_addr) && e.pathname().len() > 0) - .map(|e| e.pathname()) - .cloned(); + .into_iter() + .find(|e| e.ip_matches(base_addr) && !e.pathname.is_empty()) + .map(|e| e.pathname); if let Some(path) = opt_path { return path; } diff --git a/src/symbolize/gimli/parse_running_mmaps_unix.rs b/src/symbolize/gimli/parse_running_mmaps_unix.rs index b51476df9..da7f3a9b2 100644 --- a/src/symbolize/gimli/parse_running_mmaps_unix.rs +++ b/src/symbolize/gimli/parse_running_mmaps_unix.rs @@ -50,7 +50,7 @@ pub(super) struct MapsEntry { /// in general the pathname may be ambiguous. (I.e. you cannot tell if the /// denoted filename actually ended with the text "(deleted)", or if that /// was added by the maps rendering. - pathname: OsString, + pub(super) pathname: OsString, } pub(super) fn parse_maps() -> Result, &'static str> { @@ -70,11 +70,6 @@ pub(super) fn parse_maps() -> Result, &'static str> { } impl MapsEntry { - #[inline] - pub(super) fn pathname(&self) -> &OsString { - &self.pathname - } - #[inline] pub(super) fn ip_matches(&self, ip: usize) -> bool { self.address.0 <= ip && ip < self.address.1