Skip to content

Commit

Permalink
use matches! over match
Browse files Browse the repository at this point in the history
  • Loading branch information
Ryan-rsm-McKenzie committed Jan 27, 2024
1 parent 3d66d44 commit 84b8ab1
Showing 1 changed file with 12 additions and 15 deletions.
27 changes: 12 additions & 15 deletions src/tes4/archive.rs
Original file line number Diff line number Diff line change
Expand Up @@ -797,23 +797,20 @@ impl<'bytes> Archive<'bytes> {
source.save_restore_position(|source| -> Result<CompressableBytes<'bytes>> {
source.seek_absolute(data_offset)?;

match header.version {
Version::v104 | Version::v105 if header.archive_flags.embedded_file_names() => {
let mut s = source.read_protocol::<protocols::BString>(Endian::Little)?;
data_size -= s.len() + 1; // include prefix byte
if let Some(pos) =
s.as_bytes().iter().rposition(|&x| x == b'\\' || x == b'/')
{
if directory_name.is_none() {
*directory_name = Some(s.copy_slice(0..pos));
}
s = s.copy_slice(pos + 1..s.len());
}
if name.is_none() {
name = Some(s);
if matches!(header.version,
Version::v104 | Version::v105 if header.archive_flags.embedded_file_names())
{
let mut s = source.read_protocol::<protocols::BString>(Endian::Little)?;
data_size -= s.len() + 1; // include prefix byte
if let Some(pos) = s.as_bytes().iter().rposition(|&x| x == b'\\' || x == b'/') {
if directory_name.is_none() {
*directory_name = Some(s.copy_slice(0..pos));
}
s = s.copy_slice(pos + 1..s.len());
}
if name.is_none() {
name = Some(s);
}
_ => (),
}

let decompressed_len =
Expand Down

0 comments on commit 84b8ab1

Please sign in to comment.