clifront.c: Slightly optimized -romident so that each software list is

parsed only once instead of as many times as the number of drivers
it is attached to. Also, removed the implication that files with
(size != power of 2) are to be skipped, since we now want to identify
also tapes and floppies and not only ROM binaries. [Fabio Priuli]
This commit is contained in:
etabeta78 2015-05-13 08:17:40 +02:00
parent e674358476
commit e978f44775

View File

@ -1863,18 +1863,7 @@ void media_identifier::identify_data(const char *name, const UINT8 *data, int le
// if we didn't find it, try to guess what it might be
if (found == 0)
{
// if not a power of 2, assume it is a non-ROM file
if ((length & (length - 1)) != 0)
{
osd_printf_info("NOT A ROM\n");
m_nonroms++;
}
// otherwise, it's just not a match
else
osd_printf_info("NO MATCH\n");
}
// if we did find it, count it as a match
else
@ -1887,9 +1876,12 @@ void media_identifier::identify_data(const char *name, const UINT8 *data, int le
// of drivers by hash
//-------------------------------------------------
typedef tagmap_t<FPTR> slname_map;
int media_identifier::find_by_hash(const hash_collection &hashes, int length)
{
int found = 0;
slname_map listnames;
// iterate over drivers
m_drivlist.reset();
@ -1917,6 +1909,8 @@ int media_identifier::find_by_hash(const hash_collection &hashes, int length)
// next iterate over softlists
software_list_device_iterator iter(m_drivlist.config().root_device());
for (software_list_device *swlistdev = iter.first(); swlistdev != NULL; swlistdev = iter.next())
{
if (listnames.add(swlistdev->list_name(), 0, FALSE) != TMERR_DUPLICATE)
{
for (software_info *swinfo = swlistdev->first_software_info(); swinfo != NULL; swinfo = swinfo->next())
for (software_part *part = swinfo->first_part(); part != NULL; part = part->next())
@ -1937,6 +1931,7 @@ int media_identifier::find_by_hash(const hash_collection &hashes, int length)
}
}
}
}
return found;
}