Skip to content

Commit

Permalink
Rename confusing function
Browse files Browse the repository at this point in the history
  • Loading branch information
mitsuhiko committed Feb 21, 2023
1 parent 6c1f2e7 commit 6cd5ee0
Showing 1 changed file with 7 additions and 11 deletions.
18 changes: 7 additions & 11 deletions symbolic-debuginfo/src/sourcebundle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -855,22 +855,18 @@ impl<'data> SourceBundleDebugSession<'data> {
Ok(Some(source_content))
}

/// File info by zip path.
fn file_info_by_zip_path(&self, zip_path: &str) -> Option<&SourceFileInfo> {
self.manifest.files.get(zip_path)
}

fn lookup_source(
/// Looks up a source file descriptor.
fn get_source_file_descriptor(
&self,
key: FileKey,
) -> Result<Option<SourceFileDescriptor<'_>>, SourceBundleError> {
let zip_path = match self.indexed_files().get(&key) {
Some(zip_path) => zip_path,
Some(zip_path) => zip_path.as_str(),
None => return Ok(None),
};

let content = self.source_by_zip_path(zip_path)?;
let info = self.file_info_by_zip_path(zip_path);
let info = self.manifest.files.get(zip_path);
Ok(content.map(|opt| SourceFileDescriptor::new_embedded(Cow::Owned(opt), info)))
}

Expand All @@ -879,15 +875,15 @@ impl<'data> SourceBundleDebugSession<'data> {
&self,
path: &str,
) -> Result<Option<SourceFileDescriptor<'_>>, SourceBundleError> {
self.lookup_source(FileKey::Path(path.into()))
self.get_source_file_descriptor(FileKey::Path(path.into()))
}

/// Like [`source_by_path`](Self::source_by_path) but looks up by URL.
pub fn source_by_url(
&self,
url: &str,
) -> Result<Option<SourceFileDescriptor<'_>>, SourceBundleError> {
self.lookup_source(FileKey::Url(url.into()))
self.get_source_file_descriptor(FileKey::Url(url.into()))
}

/// Looks up some source by debug ID and file type.
Expand All @@ -908,7 +904,7 @@ impl<'data> SourceBundleDebugSession<'data> {
debug_id: DebugId,
ty: SourceFileType,
) -> Result<Option<SourceFileDescriptor<'_>>, SourceBundleError> {
self.lookup_source(FileKey::DebugId(debug_id, ty))
self.get_source_file_descriptor(FileKey::DebugId(debug_id, ty))
}
}

Expand Down

0 comments on commit 6cd5ee0

Please sign in to comment.