Eliminate many unnecessary c_str calls

This commit is contained in:
AJR 2020-12-21 22:47:30 -05:00
parent 1ed70b0181
commit 0a5d207e66
14 changed files with 29 additions and 29 deletions

View File

@ -892,7 +892,7 @@ void address_map::import_submaps(running_machine &machine, device_t &owner, int
{
mapdevice = owner.subdevice(entry->m_read.m_tag);
if (mapdevice == nullptr)
throw emu_fatalerror("Attempted to submap a non-existent device '%s' in space %d of device '%s'\n", owner.subtag(entry->m_read.m_tag).c_str(), m_spacenum, m_device->basetag());
throw emu_fatalerror("Attempted to submap a non-existent device '%s' in space %d of device '%s'\n", owner.subtag(entry->m_read.m_tag), m_spacenum, m_device->basetag());
}
// Grab the submap
@ -1296,7 +1296,7 @@ void address_map::map_validity_check(validity_checker &valid, int spacenum) cons
break;
}
if (devtag.second && !devtag.first.get().subdevice(devtag.second))
osd_printf_error("%s space memory map entry reads from nonexistent device '%s'\n", spaceconfig.m_name, devtag.first.get().subtag(devtag.second).c_str());
osd_printf_error("%s space memory map entry reads from nonexistent device '%s'\n", spaceconfig.m_name, devtag.first.get().subtag(devtag.second));
#ifndef MAME_DEBUG // assert will catch this earlier
(void)entry.unitmask_is_appropriate(entry.m_read.m_bits, entry.m_mask, entry.m_read.m_name);
#endif
@ -1368,7 +1368,7 @@ void address_map::map_validity_check(validity_checker &valid, int spacenum) cons
break;
}
if (devtag.second && !devtag.first.get().subdevice(devtag.second))
osd_printf_error("%s space memory map entry writes to nonexistent device '%s'\n", spaceconfig.m_name, devtag.first.get().subtag(devtag.second).c_str());
osd_printf_error("%s space memory map entry writes to nonexistent device '%s'\n", spaceconfig.m_name, devtag.first.get().subtag(devtag.second));
#ifndef MAME_DEBUG // assert will catch this earlier
(void)entry.unitmask_is_appropriate(entry.m_write.m_bits, entry.m_mask, entry.m_write.m_name);
#endif

View File

@ -613,7 +613,7 @@ void device_t::start()
// have the views register their state
if (!m_viewlist.empty())
osd_printf_verbose("%s: Registering %d views\n", m_tag.c_str(), int(m_viewlist.size()));
osd_printf_verbose("%s: Registering %d views\n", m_tag, int(m_viewlist.size()));
for (memory_view *view : m_viewlist)
view->register_state();

View File

@ -128,7 +128,7 @@ void device_state_entry::format_from_mask()
// make up a format based on the mask
if (m_datamask == 0)
throw emu_fatalerror("%s state entry requires a nonzero mask\n", m_symbol.c_str());
throw emu_fatalerror("%s state entry requires a nonzero mask\n", m_symbol);
int width = 0;
for (u64 tempmask = m_datamask; tempmask != 0; tempmask >>= 4)
width++;

View File

@ -960,7 +960,7 @@ void memory_bank::set_entry(int entrynum)
if (entrynum < 0 || entrynum >= int(m_entries.size()))
throw emu_fatalerror("memory_bank::set_entry called with out-of-range entry %d", entrynum);
if (m_entries[entrynum] == nullptr)
throw emu_fatalerror("memory_bank::set_entry called for bank '%s' with invalid bank entry %d", m_tag.c_str(), entrynum);
throw emu_fatalerror("memory_bank::set_entry called for bank '%s' with invalid bank entry %d", m_tag, entrynum);
m_curentry = entrynum;
}

View File

@ -885,7 +885,7 @@ emu_options::software_options emu_options::evaluate_initial_softlist_options(con
machine_config config(*m_system, *this);
software_list_device_enumerator iter(config.root_device());
if (iter.count() == 0)
throw emu_fatalerror(EMU_ERR_FATALERROR, "Error: unknown option: %s\n", software_identifier.c_str());
throw emu_fatalerror(EMU_ERR_FATALERROR, "Error: unknown option: %s\n", software_identifier);
// and finally set up the stack
std::stack<std::string> software_identifier_stack;

View File

@ -3060,7 +3060,7 @@ ioport_configurer& ioport_configurer::port_modify(const char *tag)
// find the existing port
m_curport = m_portlist.find(fulltag)->second.get();
if (m_curport == nullptr)
throw emu_fatalerror("Requested to modify nonexistent port '%s'", fulltag.c_str());
throw emu_fatalerror("Requested to modify nonexistent port '%s'", fulltag);
// bump the modification count, and reset current field/setting
m_curport->m_modcount++;
@ -3114,7 +3114,7 @@ ioport_configurer& ioport_configurer::field_add_char(std::initializer_list<char3
util::stream_format(s, "%s%d", is_first ? "" : ",", (int)ch);
is_first = false;
}
throw emu_fatalerror("PORT_CHAR(%s) could not be added - maximum amount exceeded\n", s.str().c_str());
throw emu_fatalerror("PORT_CHAR(%s) could not be added - maximum amount exceeded\n", s.str());
}

View File

@ -272,7 +272,7 @@ std::pair<const char *, device_t *> machine_config::resolve_owner(const char *ta
part.assign(tag, next - tag);
owner = owner->subdevices().find(part);
if (!owner)
throw emu_fatalerror("Could not find %s when looking up path for device %s\n", part.c_str(), orig_tag);
throw emu_fatalerror("Could not find %s when looking up path for device %s\n", part, orig_tag);
tag = next+1;
}
assert(tag[0] != '\0');

View File

@ -833,7 +833,7 @@ void sound_stream::apply_sample_rate_changes(u32 updatenum, u32 downstream_rate)
#if (SOUND_DEBUG)
void sound_stream::print_graph_recursive(int indent, int index)
{
osd_printf_info("%*s%s Ch.%d @ %d\n", indent, "", name().c_str(), index + m_output_base, sample_rate());
osd_printf_info("%*s%s Ch.%d @ %d\n", indent, "", name(), index + m_output_base, sample_rate());
for (int index = 0; index < m_input.size(); index++)
if (m_input[index].valid())
{

View File

@ -543,7 +543,7 @@ void XTAL::fail(double base_clock, const std::string &message)
else
full_message += util::string_format(" Did you mean %.0f?", xtal_error_low ? xtal_error_low : xtal_error_high);
full_message += util::string_format(" Context: %s\n", message);
fatalerror("%s\n", full_message.c_str());
fatalerror("%s\n", full_message);
}
/*

View File

@ -222,10 +222,10 @@ void cli_frontend::start_execution(mame_machine_manager *manager, const std::vec
{
// if we failed, check for no command and a system name first; in that case error on the name
if (m_options.command().empty() && mame_options::system(m_options) == nullptr && !m_options.attempted_system_name().empty())
throw emu_fatalerror(EMU_ERR_NO_SUCH_SYSTEM, "Unknown system '%s'", m_options.attempted_system_name().c_str());
throw emu_fatalerror(EMU_ERR_NO_SUCH_SYSTEM, "Unknown system '%s'", m_options.attempted_system_name());
// otherwise, error on the options
throw emu_fatalerror(EMU_ERR_INVALID_CONFIG, "%s", ex.message().c_str());
throw emu_fatalerror(EMU_ERR_INVALID_CONFIG, "%s", ex.message());
}
// determine the base name of the EXE
@ -310,7 +310,7 @@ int cli_frontend::execute(std::vector<std::string> &args)
// print them out
osd_printf_error("\n\"%s\" approximately matches the following\n"
"supported machines (best match first):\n\n", m_options.attempted_system_name().c_str());
"supported machines (best match first):\n\n", m_options.attempted_system_name());
for (int match : matches)
{
if (0 <= match)
@ -941,7 +941,7 @@ void cli_frontend::verifyroms(const std::vector<std::string> &args)
for (std::string const &pat : args)
{
if (!*it)
throw emu_fatalerror(EMU_ERR_NO_SUCH_SYSTEM, "No matching systems found for '%s'", pat.c_str());
throw emu_fatalerror(EMU_ERR_NO_SUCH_SYSTEM, "No matching systems found for '%s'", pat);
++it;
}
@ -950,9 +950,9 @@ void cli_frontend::verifyroms(const std::vector<std::string> &args)
{
// if we didn't get anything at all, display a generic end message
if (notfound > 0)
throw emu_fatalerror(EMU_ERR_MISSING_FILES, "romset \"%s\" not found!\n", args[0].c_str());
throw emu_fatalerror(EMU_ERR_MISSING_FILES, "romset \"%s\" not found!\n", args[0]);
else
throw emu_fatalerror(EMU_ERR_MISSING_FILES, "romset \"%s\" has no roms!\n", args[0].c_str());
throw emu_fatalerror(EMU_ERR_MISSING_FILES, "romset \"%s\" has no roms!\n", args[0]);
}
else
{
@ -1533,7 +1533,7 @@ template <typename T, typename U> void cli_frontend::apply_action(const std::vec
for (std::string const &pat : args)
{
if (!*it)
throw emu_fatalerror(EMU_ERR_NO_SUCH_SYSTEM, "No matching systems found for '%s'", pat.c_str());
throw emu_fatalerror(EMU_ERR_NO_SUCH_SYSTEM, "No matching systems found for '%s'", pat);
++it;
}
@ -1717,7 +1717,7 @@ void cli_frontend::execute_commands(const char *exename)
if (!m_osd.execute_command(m_options.command().c_str()))
// if we get here, we don't know what has been requested
throw emu_fatalerror(EMU_ERR_INVALID_CONFIG, "Unknown command '%s' specified", m_options.command().c_str());
throw emu_fatalerror(EMU_ERR_INVALID_CONFIG, "Unknown command '%s' specified", m_options.command());
}

View File

@ -364,7 +364,7 @@ void info_xml_creator::output(std::ostream &out, const std::vector<std::string>
if (iter != matched.end())
{
int index = iter - matched.begin();
throw emu_fatalerror(EMU_ERR_NO_SUCH_SYSTEM, "No matching machines found for '%s'", patterns[index].c_str());
throw emu_fatalerror(EMU_ERR_NO_SUCH_SYSTEM, "No matching machines found for '%s'", patterns[index]);
}
}
}

View File

@ -168,7 +168,7 @@ void mame_machine_manager::start_luaengine()
{
plugin *p = m_plugins->find(incl);
if (!p)
fatalerror("Fatal error: Could not load plugin: %s\n", incl.c_str());
fatalerror("Fatal error: Could not load plugin: %s\n", incl);
p->m_start = true;
}
@ -177,7 +177,7 @@ void mame_machine_manager::start_luaengine()
{
plugin *p = m_plugins->find(excl);
if (!p)
fatalerror("Fatal error: Unknown plugin: %s\n", excl.c_str());
fatalerror("Fatal error: Unknown plugin: %s\n", excl);
p->m_start = false;
}
}

View File

@ -157,7 +157,7 @@ bgfx_chain* chain_manager::load_chain(std::string name, uint32_t screen_index)
bx::FileReader reader;
if (!bx::open(&reader, path.c_str()))
{
osd_printf_warning("Unable to open chain file %s, falling back to no post processing\n", path.c_str());
osd_printf_warning("Unable to open chain file %s, falling back to no post processing\n", path);
return nullptr;
}
@ -176,8 +176,8 @@ bgfx_chain* chain_manager::load_chain(std::string name, uint32_t screen_index)
if (document.HasParseError())
{
std::string error(GetParseError_En(document.GetParseError()));
osd_printf_warning("Unable to parse chain %s. Errors returned:\n", path.c_str());
osd_printf_warning("%s\n", error.c_str());
osd_printf_warning("Unable to parse chain %s. Errors returned:\n", path);
osd_printf_warning("%s\n", error);
return nullptr;
}
@ -185,7 +185,7 @@ bgfx_chain* chain_manager::load_chain(std::string name, uint32_t screen_index)
if (chain == nullptr)
{
osd_printf_warning("Unable to load chain %s, falling back to no post processing\n", path.c_str());
osd_printf_warning("Unable to load chain %s, falling back to no post processing\n", path);
return nullptr;
}
@ -392,7 +392,7 @@ int32_t chain_manager::slider_changed(running_machine &machine, void *arg, int i
if (str != nullptr)
{
*str = string_format("%s", m_available_chains[m_current_chain[id]].m_name.c_str());
*str = string_format("%s", m_available_chains[m_current_chain[id]].m_name);
}
return m_current_chain[id];

View File

@ -103,7 +103,7 @@ int32_t bgfx_input_pair::texture_changed(int32_t id, std::string *str, int32_t n
file_name = file.substr(0, last_dot);
}
*str = string_format("%s", file_name.c_str());
*str = file_name;
}
return m_current_texture;