summaryrefslogtreecommitdiffstatshomepage
path: root/src/emu
diff options
context:
space:
mode:
author Vas Crabb <vas@vastheman.com>2026-04-03 02:06:01 +1100
committer Vas Crabb <vas@vastheman.com>2026-04-03 02:06:01 +1100
commit93d2609de53dbbfd6b7a4c99ce2f77cbf1def06a (patch)
tree7d292f3079b806d00fc2979f4dddbade26bc6ca6 /src/emu
parent103a6d2a294e90a74c6a9a634e8a7d259453de53 (diff)
Eliminated many temporary std::string objects.
Also updated compiling documentation. Mentioned the possibility to use the x86-64 clang/libc++/ucrt environment with MSYS2 on Windows. Removed link to tools at mamedev.org - it's trivially easy to get an up-to-date MSYS2 environment by following the instructions.
Diffstat (limited to 'src/emu')
-rw-r--r--src/emu/device.h2
-rw-r--r--src/emu/diimage.cpp2
-rw-r--r--src/emu/dislot.cpp16
-rw-r--r--src/emu/dislot.h5
-rw-r--r--src/emu/emumem.cpp18
-rw-r--r--src/emu/emumem.h22
-rw-r--r--src/emu/emuopts.cpp14
-rw-r--r--src/emu/emuopts.h18
-rw-r--r--src/emu/input.h2
-rw-r--r--src/emu/ioport.cpp2
-rw-r--r--src/emu/ioport.h2
-rw-r--r--src/emu/output.cpp2
-rw-r--r--src/emu/output.h2
-rw-r--r--src/emu/romload.cpp2
-rw-r--r--src/emu/validity.cpp12
15 files changed, 60 insertions, 61 deletions
diff --git a/src/emu/device.h b/src/emu/device.h
index 9d71746ccfd..e8834d73d56 100644
--- a/src/emu/device.h
+++ b/src/emu/device.h
@@ -512,7 +512,7 @@ class device_t : public delegate_late_bind
// private state
simple_list<device_t> m_list; // list of sub-devices we own
- std::unordered_map<std::string_view, std::reference_wrapper<device_t>> m_tagmap; // map of devices looked up and found by subtag
+ std::unordered_map<std::string_view, std::reference_wrapper<device_t> > m_tagmap; // map of devices looked up and found by subtag
};
class interface_list
diff --git a/src/emu/diimage.cpp b/src/emu/diimage.cpp
index 16cc0b0800a..6b7be6c22bd 100644
--- a/src/emu/diimage.cpp
+++ b/src/emu/diimage.cpp
@@ -758,7 +758,7 @@ std::error_condition device_image_interface::load_software(software_list_device
// handle files
if (ROMENTRY_ISFILE(romp))
{
- const software_info *const swinfo = swlist.find(std::string(swname));
+ const software_info *const swinfo = swlist.find(swname);
if (!swinfo)
return image_error::NOSOFTWARE;
diff --git a/src/emu/dislot.cpp b/src/emu/dislot.cpp
index 0dfb33e7ff1..9fd1adb0f88 100644
--- a/src/emu/dislot.cpp
+++ b/src/emu/dislot.cpp
@@ -67,7 +67,6 @@ void device_slot_interface::interface_validity_check(validity_checker &valid) co
osd_printf_error("Slot device tag conflicts with image instance name\n");
}
- // TODO: cast m_default_option to std::string_view when we have C++20
if (m_default_option && (m_options.find(m_default_option) == m_options.end()))
osd_printf_error("Default option '%s' does not correspond to any configured option\n", m_default_option);
}
@@ -94,8 +93,7 @@ device_slot_interface::slot_option &device_slot_interface::do_replace_option(std
if (name.empty())
throw emu_fatalerror("slot '%s' attempt to replace option without name\n", device().tag());
- // TODO: get rid of temporary std::string when we have C++20
- auto const found = m_options.find(std::string(name));
+ auto const found = m_options.find(name);
if (found == m_options.end())
throw emu_fatalerror("slot '%s' attempt to replace nonexistent option '%s'\n", device().tag(), name);
@@ -109,16 +107,17 @@ void device_slot_interface::option_remove(std::string_view name)
if (name.empty())
throw emu_fatalerror("slot '%s' attempt to remove option without name\n", device().tag());
- // TODO: get rid of temporary std::string when we have C++20
- if (m_options.erase(std::string(name)) == 0)
+ auto const it = m_options.find(name);
+ if (m_options.end() == it)
throw emu_fatalerror("slot '%s' attempt to remove nonexistent option '%s'\n", device().tag(), name);
+
+ m_options.erase(it);
}
device_slot_interface::slot_option &device_slot_interface::config_option(std::string_view name)
{
- // TODO: get rid of temporary std::string when we have C++20
- auto const found = m_options.find(std::string(name));
+ auto const found = m_options.find(name);
if (found != m_options.end())
return *found->second;
@@ -142,8 +141,7 @@ bool device_slot_interface::has_selectable_options() const
device_slot_interface::slot_option const *device_slot_interface::option(std::string_view name) const
{
- // TODO: get rid of temporary std::string when we have C++20
- auto const found = m_options.find(std::string(name));
+ auto const found = m_options.find(name);
if (found != m_options.end())
return found->second.get();
diff --git a/src/emu/dislot.h b/src/emu/dislot.h
index 75308b42ce0..ae09a76565f 100644
--- a/src/emu/dislot.h
+++ b/src/emu/dislot.h
@@ -9,11 +9,12 @@
#ifndef MAME_EMU_DISLOT_H
#define MAME_EMU_DISLOT_H
+#include "coretmpl.h"
+
#include <functional>
#include <memory>
#include <string>
#include <string_view>
-#include <unordered_map>
//**************************************************************************
@@ -83,7 +84,7 @@ public:
};
using slot_option_ptr = std::unique_ptr<slot_option>;
- using slot_option_map = std::unordered_map<std::string, slot_option_ptr>;
+ using slot_option_map = util::transparent_string_unordered_map<std::string, slot_option_ptr>;
virtual ~device_slot_interface();
diff --git a/src/emu/emumem.cpp b/src/emu/emumem.cpp
index 8ded039028f..9c75cc49681 100644
--- a/src/emu/emumem.cpp
+++ b/src/emu/emumem.cpp
@@ -349,10 +349,10 @@ memory_region *memory_manager::region_alloc(std::string name, u32 length, u8 wid
// region_find - find a region by name
//-------------------------------------------------
-memory_region *memory_manager::region_find(std::string name)
+memory_region *memory_manager::region_find(std::string_view name)
{
- auto i = m_regionlist.find(name);
- return i != m_regionlist.end() ? i->second.get() : nullptr;
+ auto const i = m_regionlist.find(name);
+ return (i != m_regionlist.end()) ? i->second.get() : nullptr;
}
@@ -399,10 +399,10 @@ memory_share *memory_manager::share_alloc(device_t &dev, std::string name, u8 wi
// share_find - find a share by name
//-------------------------------------------------
-memory_share *memory_manager::share_find(std::string name)
+memory_share *memory_manager::share_find(std::string_view name)
{
- auto i = m_sharelist.find(name);
- return i != m_sharelist.end() ? i->second.get() : nullptr;
+ auto const i = m_sharelist.find(name);
+ return (i != m_sharelist.end()) ? i->second.get() : nullptr;
}
@@ -428,10 +428,10 @@ memory_bank *memory_manager::bank_alloc(device_t &device, std::string name)
// bank_find - find a bank by name
//-------------------------------------------------
-memory_bank *memory_manager::bank_find(std::string name)
+memory_bank *memory_manager::bank_find(std::string_view name)
{
- auto i = m_banklist.find(name);
- return i != m_banklist.end() ? i->second.get() : nullptr;
+ auto const i = m_banklist.find(name);
+ return (i != m_banklist.end()) ? i->second.get() : nullptr;
}
diff --git a/src/emu/emumem.h b/src/emu/emumem.h
index 6db90288db5..8020d56d67f 100644
--- a/src/emu/emumem.h
+++ b/src/emu/emumem.h
@@ -18,10 +18,12 @@
#define MAME_EMU_EMUMEM_H
#include "notifier.h"
+#include "coretmpl.h"
#include <cstdlib>
#include <optional>
#include <set>
+#include <string_view>
#include <type_traits>
using s8 = std::int8_t;
@@ -2714,24 +2716,24 @@ public:
running_machine &machine() const { return m_machine; }
// used for the debugger interface memory views
- const std::unordered_map<std::string, std::unique_ptr<memory_bank>> &banks() const { return m_banklist; }
- const std::unordered_map<std::string, std::unique_ptr<memory_region>> &regions() const { return m_regionlist; }
- const std::unordered_map<std::string, std::unique_ptr<memory_share>> &shares() const { return m_sharelist; }
+ const util::transparent_string_unordered_map<std::string, std::unique_ptr<memory_bank>> &banks() const { return m_banklist; }
+ const util::transparent_string_unordered_map<std::string, std::unique_ptr<memory_region>> &regions() const { return m_regionlist; }
+ const util::transparent_string_unordered_map<std::string, std::unique_ptr<memory_share>> &shares() const { return m_sharelist; }
// anonymous memory zones
void *anonymous_alloc(address_space &space, size_t bytes, u8 width, offs_t start, offs_t end, const std::string &key = "");
// shares
memory_share *share_alloc(device_t &dev, std::string name, u8 width, size_t bytes, endianness_t endianness);
- memory_share *share_find(std::string name);
+ memory_share *share_find(std::string_view name);
// banks
memory_bank *bank_alloc(device_t &device, std::string tag);
- memory_bank *bank_find(std::string tag);
+ memory_bank *bank_find(std::string_view tag);
// regions
memory_region *region_alloc(std::string name, u32 length, u8 width, endianness_t endian);
- memory_region *region_find(std::string name);
+ memory_region *region_find(std::string_view name);
void region_free(std::string name);
private:
@@ -2740,10 +2742,10 @@ private:
// internal state
running_machine & m_machine; // reference to the machine
- std::vector<std::unique_ptr<void, stdlib_deleter>> m_datablocks; // list of memory blocks to free on exit
- std::unordered_map<std::string, std::unique_ptr<memory_bank>> m_banklist; // map of banks
- std::unordered_map<std::string, std::unique_ptr<memory_share>> m_sharelist; // map of shares
- std::unordered_map<std::string, std::unique_ptr<memory_region>> m_regionlist; // map of memory regions
+ std::vector<std::unique_ptr<void, stdlib_deleter>> m_datablocks; // list of memory blocks to free on exit
+ util::transparent_string_unordered_map<std::string, std::unique_ptr<memory_bank>> m_banklist; // map of banks
+ util::transparent_string_unordered_map<std::string, std::unique_ptr<memory_share>> m_sharelist; // map of shares
+ util::transparent_string_unordered_map<std::string, std::unique_ptr<memory_region>> m_regionlist; // map of memory regions
// Allocate the address spaces
void allocate(device_memory_interface &memory);
diff --git a/src/emu/emuopts.cpp b/src/emu/emuopts.cpp
index 8f9177e6d4b..dc50597cef8 100644
--- a/src/emu/emuopts.cpp
+++ b/src/emu/emuopts.cpp
@@ -357,7 +357,7 @@ namespace
class existing_option_tracker
{
public:
- existing_option_tracker(const std::unordered_map<std::string, T> &map)
+ existing_option_tracker(const util::transparent_string_unordered_map<std::string, T> &map)
{
m_vec.reserve(map.size());
for (const auto &entry : map)
@@ -1027,15 +1027,13 @@ emu_options::software_options emu_options::evaluate_initial_softlist_options(con
const slot_option *emu_options::find_slot_option(std::string_view device_name) const
{
- // TODO: get rid of temporary std::string when we have C++20
- auto const iter = m_slot_options.find(std::string(device_name));
+ auto const iter = m_slot_options.find(device_name);
return (iter != m_slot_options.end()) ? &iter->second : nullptr;
}
slot_option *emu_options::find_slot_option(std::string_view device_name)
{
- // TODO: get rid of temporary std::string when we have C++20
- auto const iter = m_slot_options.find(std::string(device_name));
+ auto const iter = m_slot_options.find(device_name);
return (iter != m_slot_options.end()) ? &iter->second : nullptr;
}
@@ -1066,16 +1064,14 @@ slot_option &emu_options::slot_option(std::string_view device_name)
const image_option &emu_options::image_option(std::string_view device_name) const
{
- // TODO: get rid of temporary std::string when we have C++20
- auto const iter = m_image_options.find(std::string(device_name));
+ auto const iter = m_image_options.find(device_name);
assert(iter != m_image_options.end() && "Attempt to access non-existent image option");
return *iter->second;
}
image_option &emu_options::image_option(std::string_view device_name)
{
- // TODO: get rid of temporary std::string when we have C++20
- auto const iter = m_image_options.find(std::string(device_name));
+ auto const iter = m_image_options.find(device_name);
assert(iter != m_image_options.end() && "Attempt to access non-existent image option");
return *iter->second;
}
diff --git a/src/emu/emuopts.h b/src/emu/emuopts.h
index 10fdbb771d6..87e28ebea3c 100644
--- a/src/emu/emuopts.h
+++ b/src/emu/emuopts.h
@@ -14,6 +14,8 @@
#pragma once
#include "options.h"
+#include "coretmpl.h"
+
#define OPTION_PRIORITY_CMDLINE OPTION_PRIORITY_HIGH + 1
// core options
@@ -488,10 +490,10 @@ public:
::slot_option &slot_option(std::string_view device_name);
const ::slot_option *find_slot_option(std::string_view device_name) const;
::slot_option *find_slot_option(std::string_view device_name);
- bool has_slot_option(std::string_view device_name) const { return bool(find_slot_option(std::string(device_name))); } // TODO: get rid of temporary std::string when we have C++20
+ bool has_slot_option(std::string_view device_name) const { return bool(find_slot_option(device_name)); }
const ::image_option &image_option(std::string_view device_name) const;
::image_option &image_option(std::string_view device_name);
- bool has_image_option(std::string_view device_name) const { return m_image_options.find(std::string(device_name)) != m_image_options.end(); } // TODO: get rid of temporary std::string when we have C++20
+ bool has_image_option(std::string_view device_name) const { return m_image_options.find(device_name) != m_image_options.end(); }
protected:
virtual void command_argument_processed() override;
@@ -499,9 +501,9 @@ protected:
private:
struct software_options
{
- std::unordered_map<std::string, std::string> slot;
- std::unordered_map<std::string, std::string> slot_defaults;
- std::unordered_map<std::string, std::string> image;
+ util::transparent_string_unordered_map<std::string, std::string> slot;
+ util::transparent_string_unordered_map<std::string, std::string> slot_defaults;
+ util::transparent_string_unordered_map<std::string, std::string> image;
};
// slot/image/softlist calculus
@@ -520,9 +522,9 @@ private:
const game_driver * m_system;
// slots and devices
- std::unordered_map<std::string, ::slot_option> m_slot_options;
- std::unordered_map<std::string, ::image_option> m_image_options_canonical;
- std::unordered_map<std::string, ::image_option *> m_image_options;
+ util::transparent_string_unordered_map<std::string, ::slot_option> m_slot_options;
+ util::transparent_string_unordered_map<std::string, ::image_option> m_image_options_canonical;
+ util::transparent_string_unordered_map<std::string, ::image_option *> m_image_options;
// cached options, for scenarios where parsing core_options is too slow
int m_coin_impulse;
diff --git a/src/emu/input.h b/src/emu/input.h
index 7c00a590a8d..68ef7475dfc 100644
--- a/src/emu/input.h
+++ b/src/emu/input.h
@@ -45,7 +45,7 @@ class input_manager : public osd::input_manager
{
public:
// controller alias table typedef
- using devicemap_table = std::map<std::string, std::string>;
+ using devicemap_table = util::transparent_string_map<std::string, std::string>;
// construction/destruction
input_manager(running_machine &machine);
diff --git a/src/emu/ioport.cpp b/src/emu/ioport.cpp
index 8c4cd18e8c2..fc5a0de293c 100644
--- a/src/emu/ioport.cpp
+++ b/src/emu/ioport.cpp
@@ -2661,7 +2661,7 @@ void ioport_manager::load_system_config(
if (parent_device)
{
device_slot_interface const *slot;
- if (parent_device->interface(slot) && (slot->option_list().find(std::string(child_tag)) != slot->option_list().end()))
+ if (parent_device->interface(slot) && (slot->option_list().find(child_tag) != slot->option_list().end()))
{
if (!m_deselected_card_config)
m_deselected_card_config = util::xml::file::create();
diff --git a/src/emu/ioport.h b/src/emu/ioport.h
index 945d58b3a04..d018cdf1ffa 100644
--- a/src/emu/ioport.h
+++ b/src/emu/ioport.h
@@ -736,7 +736,7 @@ struct ioport_field_live
// ======================> ioport_list
// class that holds a list of I/O ports
-class ioport_list : public std::map<std::string, std::unique_ptr<ioport_port>>
+class ioport_list : public util::transparent_string_map<std::string, std::unique_ptr<ioport_port> >
{
DISABLE_COPYING(ioport_list);
diff --git a/src/emu/output.cpp b/src/emu/output.cpp
index 95b92cfc5d0..1d95d199edc 100644
--- a/src/emu/output.cpp
+++ b/src/emu/output.cpp
@@ -118,7 +118,7 @@ void output_manager::register_save()
output_manager::output_item *output_manager::find_item(std::string_view string)
{
- auto item = m_itemtable.find(std::string(string));
+ auto item = m_itemtable.find(string);
if (item != m_itemtable.end())
return &item->second;
diff --git a/src/emu/output.h b/src/emu/output.h
index 79c0c61eb16..4c4a2d5c6ce 100644
--- a/src/emu/output.h
+++ b/src/emu/output.h
@@ -207,7 +207,7 @@ private:
// internal state
running_machine &m_machine; // reference to our machine
- std::unordered_map<std::string, output_item> m_itemtable;
+ util::transparent_string_unordered_map<std::string, output_item> m_itemtable;
notify_vector m_global_notifylist;
std::vector<std::reference_wrapper<output_item> > m_save_order;
std::unique_ptr<s32 []> m_save_data;
diff --git a/src/emu/romload.cpp b/src/emu/romload.cpp
index e23f518dede..dad119219ee 100644
--- a/src/emu/romload.cpp
+++ b/src/emu/romload.cpp
@@ -1365,7 +1365,7 @@ void rom_load_manager::load_software_part_region(device_t &device, software_list
std::vector<const software_info *> parents;
std::vector<std::string> swsearch, disksearch;
- const software_info *const swinfo = swlist.find(std::string(swname));
+ const software_info *const swinfo = swlist.find(swname);
if (swinfo)
{
// display a warning for unsupported software
diff --git a/src/emu/validity.cpp b/src/emu/validity.cpp
index e6e2512d9a6..8fe11e39e16 100644
--- a/src/emu/validity.cpp
+++ b/src/emu/validity.cpp
@@ -249,9 +249,9 @@ void validate_inlines()
osd_printf_error("Error testing mulu_32x32_shift (%08X x %08X) >> 7 = %08X (expected %08X)\n", u32(testu32a), u32(testu32b), resultu32, expectedu32);
while (s64(testi32a) * s64(0x7fffffff) < testi64a)
- testi64a /= 2;
+ testi64a = testi64a / 2;
while (u64(testu32a) * u64(bigu32) < testu64a)
- testu64a /= 2;
+ testu64a = testu64a / 2;
resulti32 = div_64x32(testi64a, testi32a);
expectedi32 = testi64a / s64(testi32a);
@@ -286,9 +286,9 @@ void validate_inlines()
osd_printf_error("Error testing modu_64x32 (%16X / %08X) = %08X (expected %08X)\n", u64(testu64a), u32(testu32a), resultu32, expectedu32);
while (s64(testi32a) * s64(0x7fffffff) < (s32(testi64a) << 3))
- testi64a /= 2;
+ testi64a = testi64a / 2;
while (u64(testu32a) * u64(0xffffffff) < (u32(testu64a) << 3))
- testu64a /= 2;
+ testu64a = testu64a / 2;
resulti32 = div_32x32_shift(s32(testi64a), testi32a, 3);
expectedi32 = (s64(s32(testi64a)) << 3) / s64(testi32a);
@@ -327,7 +327,7 @@ void validate_inlines()
if (resultu32l != expected32)
osd_printf_error("Error testing rotl_32 %08x, %d=%08x (expected %08x)\n", u32(testu32a), -i, resultu32l, expected32);
- expected32 = expected32 >> 1 | expected32 << 31;
+ expected32 = (expected32 >> 1) | (expected32 << 31);
}
u64 expected64 = testu64a << 1 | testu64a >> 63;
@@ -341,7 +341,7 @@ void validate_inlines()
if (resultu64l != expected64)
osd_printf_error("Error testing rotl_64 %016x, %d=%016x (expected %016x)\n", u64(testu64a), -i, resultu64l, expected64);
- expected64 = expected64 >> 1 | expected64 << 63;
+ expected64 = (expected64 >> 1) | (expected64 << 63);
}
}