summaryrefslogtreecommitdiffstatshomepage
path: root/src/lib/util/chd.cpp
diff options
context:
space:
mode:
author Vas Crabb <vas@vastheman.com>2025-03-01 00:21:01 +1100
committer Vas Crabb <vas@vastheman.com>2025-03-01 00:21:01 +1100
commit0a861ff810f00554e6b16e329018918434009774 (patch)
treea36bca71eb4e260b8dc92e77d2802cd3bda972d4 /src/lib/util/chd.cpp
parentde2026bcaaa403f7f1561e8edb284d675d588d8a (diff)
Cleaned up some stuff:
* oberheim/xpander.cpp: Use multi-dimensional output finders algorithms and range-based for loops. * util/chd.cpp: Use a C++17ism to reduce if nesting a bit. * sound/tms5220.cpp: Five an example VERBOSE value that will actually do something rather than LOG_GENERAL which isn't used in the file at all.
Diffstat (limited to 'src/lib/util/chd.cpp')
-rw-r--r--src/lib/util/chd.cpp32
1 files changed, 13 insertions, 19 deletions
diff --git a/src/lib/util/chd.cpp b/src/lib/util/chd.cpp
index 9395bb39c45..c05977a84eb 100644
--- a/src/lib/util/chd.cpp
+++ b/src/lib/util/chd.cpp
@@ -3108,31 +3108,25 @@ std::error_condition chd_file_compressor::compress_continue(double &progress, do
if (!err && codec == CHD_CODEC_NONE) // TODO: report error?
m_total_out += m_hunkbytes;
}
+ else if (uint64_t const selfhunk = m_current_map.find(item.m_hash[0].m_crc16, item.m_hash[0].m_sha1); selfhunk != hashmap::NOT_FOUND)
+ {
+ // the hunk is in the self map
+ hunk_copy_from_self(item.m_hunknum, selfhunk);
+ }
else
{
- // for compressing, process the result
-
- // first see if the hunk is in the parent or self maps
- uint64_t selfhunk = m_current_map.find(item.m_hash[0].m_crc16, item.m_hash[0].m_sha1);
- if (selfhunk != hashmap::NOT_FOUND)
+ // if not, see if it's in the parent map
+ uint64_t const parentunit = m_parent ? m_parent_map.find(item.m_hash[0].m_crc16, item.m_hash[0].m_sha1) : hashmap::NOT_FOUND;
+ if (parentunit != hashmap::NOT_FOUND)
{
- hunk_copy_from_self(item.m_hunknum, selfhunk);
+ hunk_copy_from_parent(item.m_hunknum, parentunit);
}
else
{
- // if not, see if it's in the parent map
- uint64_t const parentunit = m_parent ? m_parent_map.find(item.m_hash[0].m_crc16, item.m_hash[0].m_sha1) : hashmap::NOT_FOUND;
- if (parentunit != hashmap::NOT_FOUND)
- {
- hunk_copy_from_parent(item.m_hunknum, parentunit);
- }
- else
- {
- // otherwise, append it compressed and add to the self map
- hunk_write_compressed(item.m_hunknum, item.m_compression, item.m_compressed, item.m_complen, item.m_hash[0].m_crc16);
- m_total_out += item.m_complen;
- m_current_map.add(item.m_hunknum, item.m_hash[0].m_crc16, item.m_hash[0].m_sha1);
- }
+ // otherwise, append it compressed and add to the self map
+ hunk_write_compressed(item.m_hunknum, item.m_compression, item.m_compressed, item.m_complen, item.m_hash[0].m_crc16);
+ m_total_out += item.m_complen;
+ m_current_map.add(item.m_hunknum, item.m_hash[0].m_crc16, item.m_hash[0].m_sha1);
}
}