diff options
author | 2016-01-11 09:18:43 +0100 | |
---|---|---|
committer | 2016-01-11 09:18:43 +0100 | |
commit | 36195292e370de0fb6b32085c105a236995ce36e (patch) | |
tree | 1fb147c3e21824272b60e4989f606bc9c206030c /src/emu/emuopts.cpp | |
parent | 7c944fa3b02cd26dec3c27f1e6a4c0d33f462c4e (diff) | |
parent | 115db95642ad6d861aad63775b92350e0491f2dd (diff) |
Merge pull request #561 from ajrhacker/strings
Return std::string objects by value rather than pass by reference [ajrhacker]
Diffstat (limited to 'src/emu/emuopts.cpp')
-rw-r--r-- | src/emu/emuopts.cpp | 23 |
1 files changed, 10 insertions, 13 deletions
diff --git a/src/emu/emuopts.cpp b/src/emu/emuopts.cpp index c27064b1521..aa1b0482edc 100644 --- a/src/emu/emuopts.cpp +++ b/src/emu/emuopts.cpp @@ -281,8 +281,7 @@ void emu_options::update_slot_options() const char *name = slot->device().tag() + 1; if (exists(name) && slot->first_option() != nullptr) { - std::string defvalue; - slot->get_default_card_software(defvalue); + std::string defvalue = slot->get_default_card_software(); if (defvalue.length() > 0) { set_default_value(name, defvalue.c_str()); @@ -470,11 +469,10 @@ void emu_options::parse_standard_inis(std::string &error_string) } // next parse "source/<sourcefile>.ini"; if that doesn't exist, try <sourcefile>.ini - std::string sourcename; - core_filename_extract_base(sourcename, cursystem->source_file, true).insert(0, "source" PATH_SEPARATOR); + std::string sourcename = core_filename_extract_base(cursystem->source_file, true).insert(0, "source" PATH_SEPARATOR); if (!parse_one_ini(sourcename.c_str(), OPTION_PRIORITY_SOURCE_INI, &error_string)) { - core_filename_extract_base(sourcename, cursystem->source_file, true); + sourcename = core_filename_extract_base(cursystem->source_file, true); parse_one_ini(sourcename.c_str(), OPTION_PRIORITY_SOURCE_INI, &error_string); } @@ -501,8 +499,7 @@ void emu_options::parse_standard_inis(std::string &error_string) const game_driver *emu_options::system() const { - std::string tempstr; - int index = driver_list::find(core_filename_extract_base(tempstr, system_name(), true).c_str()); + int index = driver_list::find(core_filename_extract_base(system_name(), true).c_str()); return (index != -1) ? &driver_list::driver(index) : nullptr; } @@ -568,19 +565,19 @@ bool emu_options::parse_one_ini(const char *basename, int priority, std::string } -const char *emu_options::main_value(std::string &buffer, const char *name) const +std::string emu_options::main_value(const char *name) const { - buffer = value(name); + std::string buffer = value(name); int pos = buffer.find_first_of(','); if (pos != -1) buffer = buffer.substr(0, pos); - return buffer.c_str(); + return buffer; } -const char *emu_options::sub_value(std::string &buffer, const char *name, const char *subname) const +std::string emu_options::sub_value(const char *name, const char *subname) const { std::string tmp = std::string(",").append(subname).append("="); - buffer = value(name); + std::string buffer = value(name); int pos = buffer.find(tmp); if (pos != -1) { @@ -591,7 +588,7 @@ const char *emu_options::sub_value(std::string &buffer, const char *name, const } else buffer.clear(); - return buffer.c_str(); + return buffer; } |