mirror of
https://github.com/holub/mame
synced 2025-04-25 09:50:04 +03:00
Shared_ptr ==> unique_ptr. (nw)
This commit is contained in:
parent
14a5f0143e
commit
badb2a903b
@ -51,7 +51,7 @@ namespace plib
|
||||
{
|
||||
indexed_compare(const C& target): m_target(target) {}
|
||||
|
||||
bool operator()(int a, int b) const { return m_target[a] < m_target[b]; }
|
||||
bool operator()(int a, int b) const { return *m_target[a] < *m_target[b]; }
|
||||
|
||||
const C& m_target;
|
||||
};
|
||||
|
@ -18,7 +18,7 @@
|
||||
void nl_convert_base_t::add_pin_alias(const pstring &devname, const pstring &name, const pstring &alias)
|
||||
{
|
||||
pstring pname = devname + "." + name;
|
||||
m_pins.insert({pname, plib::make_unique<pin_alias_t>(pname, devname + "." + alias)});
|
||||
m_pins.emplace(pname, plib::make_unique<pin_alias_t>(pname, devname + "." + alias));
|
||||
}
|
||||
|
||||
void nl_convert_base_t::add_ext_alias(const pstring &alias)
|
||||
@ -26,7 +26,7 @@ void nl_convert_base_t::add_ext_alias(const pstring &alias)
|
||||
m_ext_alias.push_back(alias);
|
||||
}
|
||||
|
||||
void nl_convert_base_t::add_device(std::shared_ptr<dev_t> dev)
|
||||
void nl_convert_base_t::add_device(std::unique_ptr<dev_t> dev)
|
||||
{
|
||||
for (auto & d : m_devs)
|
||||
if (d->name() == dev->name())
|
||||
@ -34,20 +34,20 @@ void nl_convert_base_t::add_device(std::shared_ptr<dev_t> dev)
|
||||
out("ERROR: Duplicate device {1} ignored.", dev->name());
|
||||
return;
|
||||
}
|
||||
m_devs.push_back(dev);
|
||||
m_devs.push_back(std::move(dev));
|
||||
}
|
||||
|
||||
void nl_convert_base_t::add_device(const pstring &atype, const pstring &aname, const pstring &amodel)
|
||||
{
|
||||
add_device(std::make_shared<dev_t>(atype, aname, amodel));
|
||||
add_device(plib::make_unique<dev_t>(atype, aname, amodel));
|
||||
}
|
||||
void nl_convert_base_t::add_device(const pstring &atype, const pstring &aname, double aval)
|
||||
{
|
||||
add_device(std::make_shared<dev_t>(atype, aname, aval));
|
||||
add_device(plib::make_unique<dev_t>(atype, aname, aval));
|
||||
}
|
||||
void nl_convert_base_t::add_device(const pstring &atype, const pstring &aname)
|
||||
{
|
||||
add_device(std::make_shared<dev_t>(atype, aname));
|
||||
add_device(plib::make_unique<dev_t>(atype, aname));
|
||||
}
|
||||
|
||||
void nl_convert_base_t::add_term(pstring netname, pstring termname)
|
||||
@ -58,9 +58,9 @@ void nl_convert_base_t::add_term(pstring netname, pstring termname)
|
||||
net = m_nets[netname].get();
|
||||
else
|
||||
{
|
||||
auto nets = std::make_shared<net_t>(netname);
|
||||
auto nets = plib::make_unique<net_t>(netname);
|
||||
net = nets.get();
|
||||
m_nets.insert({netname, nets});
|
||||
m_nets.emplace(netname, std::move(nets));
|
||||
}
|
||||
|
||||
/* if there is a pin alias, translate ... */
|
||||
@ -84,10 +84,11 @@ void nl_convert_base_t::dump_nl()
|
||||
net->set_no_export();
|
||||
}
|
||||
|
||||
std::vector<int> sorted;
|
||||
for (unsigned i=0; i < m_devs.size(); i++)
|
||||
std::vector<size_t> sorted;
|
||||
for (size_t i=0; i < m_devs.size(); i++)
|
||||
sorted.push_back(i);
|
||||
std::sort(sorted.begin(), sorted.end(), plib::indexed_compare<std::vector<std::shared_ptr<dev_t>>>(m_devs));
|
||||
std::sort(sorted.begin(), sorted.end(),
|
||||
[&](size_t i1, size_t i2) { return m_devs[i1]->name() < m_devs[i2]->name(); });
|
||||
|
||||
for (std::size_t i=0; i<m_devs.size(); i++)
|
||||
{
|
||||
|
@ -126,14 +126,14 @@ private:
|
||||
|
||||
private:
|
||||
|
||||
void add_device(std::shared_ptr<dev_t> dev);
|
||||
void add_device(std::unique_ptr<dev_t> dev);
|
||||
|
||||
plib::postringstream m_buf;
|
||||
|
||||
std::vector<std::shared_ptr<dev_t>> m_devs;
|
||||
std::unordered_map<pstring, std::shared_ptr<net_t> > m_nets;
|
||||
std::vector<std::unique_ptr<dev_t>> m_devs;
|
||||
std::unordered_map<pstring, std::unique_ptr<net_t> > m_nets;
|
||||
std::vector<pstring> m_ext_alias;
|
||||
std::unordered_map<pstring, std::shared_ptr<pin_alias_t>> m_pins;
|
||||
std::unordered_map<pstring, std::unique_ptr<pin_alias_t>> m_pins;
|
||||
|
||||
static unit_t m_units[];
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user