mirror of
https://github.com/YosysHQ/yosys
synced 2026-05-02 08:33:46 +00:00
Pass IdString by value instead of by const reference.
When IdString refcounting was expensive, it made sense to pass it by const reference instead of by value, to avoid refcount churn. Now that IdString is not refcounted, it's slightly more efficient to pass it by value.
This commit is contained in:
parent
64a933d77b
commit
46cb05c471
15 changed files with 108 additions and 108 deletions
|
|
@ -1017,12 +1017,12 @@ RTLIL::Const RTLIL::Const::extract(int offset, int len, RTLIL::State padding) co
|
|||
}
|
||||
#undef check /* check(condition) for Const */
|
||||
|
||||
bool RTLIL::AttrObject::has_attribute(const RTLIL::IdString &id) const
|
||||
bool RTLIL::AttrObject::has_attribute(RTLIL::IdString id) const
|
||||
{
|
||||
return attributes.count(id);
|
||||
}
|
||||
|
||||
void RTLIL::AttrObject::set_bool_attribute(const RTLIL::IdString &id, bool value)
|
||||
void RTLIL::AttrObject::set_bool_attribute(RTLIL::IdString id, bool value)
|
||||
{
|
||||
if (value)
|
||||
attributes[id] = RTLIL::Const(1);
|
||||
|
|
@ -1030,7 +1030,7 @@ void RTLIL::AttrObject::set_bool_attribute(const RTLIL::IdString &id, bool value
|
|||
attributes.erase(id);
|
||||
}
|
||||
|
||||
bool RTLIL::AttrObject::get_bool_attribute(const RTLIL::IdString &id) const
|
||||
bool RTLIL::AttrObject::get_bool_attribute(RTLIL::IdString id) const
|
||||
{
|
||||
const auto it = attributes.find(id);
|
||||
if (it == attributes.end())
|
||||
|
|
@ -1038,7 +1038,7 @@ bool RTLIL::AttrObject::get_bool_attribute(const RTLIL::IdString &id) const
|
|||
return it->second.as_bool();
|
||||
}
|
||||
|
||||
void RTLIL::AttrObject::set_string_attribute(const RTLIL::IdString& id, string value)
|
||||
void RTLIL::AttrObject::set_string_attribute(RTLIL::IdString id, string value)
|
||||
{
|
||||
if (value.empty())
|
||||
attributes.erase(id);
|
||||
|
|
@ -1046,7 +1046,7 @@ void RTLIL::AttrObject::set_string_attribute(const RTLIL::IdString& id, string v
|
|||
attributes[id] = value;
|
||||
}
|
||||
|
||||
string RTLIL::AttrObject::get_string_attribute(const RTLIL::IdString &id) const
|
||||
string RTLIL::AttrObject::get_string_attribute(RTLIL::IdString id) const
|
||||
{
|
||||
std::string value;
|
||||
const auto it = attributes.find(id);
|
||||
|
|
@ -1055,7 +1055,7 @@ string RTLIL::AttrObject::get_string_attribute(const RTLIL::IdString &id) const
|
|||
return value;
|
||||
}
|
||||
|
||||
void RTLIL::AttrObject::set_strpool_attribute(const RTLIL::IdString& id, const pool<string> &data)
|
||||
void RTLIL::AttrObject::set_strpool_attribute(RTLIL::IdString id, const pool<string> &data)
|
||||
{
|
||||
string attrval;
|
||||
for (const auto &s : data) {
|
||||
|
|
@ -1066,7 +1066,7 @@ void RTLIL::AttrObject::set_strpool_attribute(const RTLIL::IdString& id, const p
|
|||
set_string_attribute(id, attrval);
|
||||
}
|
||||
|
||||
void RTLIL::AttrObject::add_strpool_attribute(const RTLIL::IdString& id, const pool<string> &data)
|
||||
void RTLIL::AttrObject::add_strpool_attribute(RTLIL::IdString id, const pool<string> &data)
|
||||
{
|
||||
pool<string> union_data = get_strpool_attribute(id);
|
||||
union_data.insert(data.begin(), data.end());
|
||||
|
|
@ -1074,7 +1074,7 @@ void RTLIL::AttrObject::add_strpool_attribute(const RTLIL::IdString& id, const p
|
|||
set_strpool_attribute(id, union_data);
|
||||
}
|
||||
|
||||
pool<string> RTLIL::AttrObject::get_strpool_attribute(const RTLIL::IdString &id) const
|
||||
pool<string> RTLIL::AttrObject::get_strpool_attribute(RTLIL::IdString id) const
|
||||
{
|
||||
pool<string> data;
|
||||
if (attributes.count(id) != 0)
|
||||
|
|
@ -1099,7 +1099,7 @@ vector<string> RTLIL::AttrObject::get_hdlname_attribute() const
|
|||
return split_tokens(get_string_attribute(ID::hdlname), " ");
|
||||
}
|
||||
|
||||
void RTLIL::AttrObject::set_intvec_attribute(const RTLIL::IdString& id, const vector<int> &data)
|
||||
void RTLIL::AttrObject::set_intvec_attribute(RTLIL::IdString id, const vector<int> &data)
|
||||
{
|
||||
std::stringstream attrval;
|
||||
for (auto &i : data) {
|
||||
|
|
@ -1110,7 +1110,7 @@ void RTLIL::AttrObject::set_intvec_attribute(const RTLIL::IdString& id, const ve
|
|||
attributes[id] = RTLIL::Const(attrval.str());
|
||||
}
|
||||
|
||||
vector<int> RTLIL::AttrObject::get_intvec_attribute(const RTLIL::IdString &id) const
|
||||
vector<int> RTLIL::AttrObject::get_intvec_attribute(RTLIL::IdString id) const
|
||||
{
|
||||
vector<int> data;
|
||||
auto it = attributes.find(id);
|
||||
|
|
@ -1128,7 +1128,7 @@ vector<int> RTLIL::AttrObject::get_intvec_attribute(const RTLIL::IdString &id) c
|
|||
return data;
|
||||
}
|
||||
|
||||
bool RTLIL::Selection::boxed_module(const RTLIL::IdString &mod_name) const
|
||||
bool RTLIL::Selection::boxed_module(RTLIL::IdString mod_name) const
|
||||
{
|
||||
if (current_design != nullptr) {
|
||||
auto module = current_design->module(mod_name);
|
||||
|
|
@ -1139,7 +1139,7 @@ bool RTLIL::Selection::boxed_module(const RTLIL::IdString &mod_name) const
|
|||
}
|
||||
}
|
||||
|
||||
bool RTLIL::Selection::selected_module(const RTLIL::IdString &mod_name) const
|
||||
bool RTLIL::Selection::selected_module(RTLIL::IdString mod_name) const
|
||||
{
|
||||
if (complete_selection)
|
||||
return true;
|
||||
|
|
@ -1154,7 +1154,7 @@ bool RTLIL::Selection::selected_module(const RTLIL::IdString &mod_name) const
|
|||
return false;
|
||||
}
|
||||
|
||||
bool RTLIL::Selection::selected_whole_module(const RTLIL::IdString &mod_name) const
|
||||
bool RTLIL::Selection::selected_whole_module(RTLIL::IdString mod_name) const
|
||||
{
|
||||
if (complete_selection)
|
||||
return true;
|
||||
|
|
@ -1167,7 +1167,7 @@ bool RTLIL::Selection::selected_whole_module(const RTLIL::IdString &mod_name) co
|
|||
return false;
|
||||
}
|
||||
|
||||
bool RTLIL::Selection::selected_member(const RTLIL::IdString &mod_name, const RTLIL::IdString &memb_name) const
|
||||
bool RTLIL::Selection::selected_member(RTLIL::IdString mod_name, RTLIL::IdString memb_name) const
|
||||
{
|
||||
if (complete_selection)
|
||||
return true;
|
||||
|
|
@ -1294,12 +1294,12 @@ RTLIL::ObjRange<RTLIL::Module*> RTLIL::Design::modules()
|
|||
return RTLIL::ObjRange<RTLIL::Module*>(&modules_, &refcount_modules_);
|
||||
}
|
||||
|
||||
RTLIL::Module *RTLIL::Design::module(const RTLIL::IdString& name)
|
||||
RTLIL::Module *RTLIL::Design::module(RTLIL::IdString name)
|
||||
{
|
||||
return modules_.count(name) ? modules_.at(name) : NULL;
|
||||
}
|
||||
|
||||
const RTLIL::Module *RTLIL::Design::module(const RTLIL::IdString& name) const
|
||||
const RTLIL::Module *RTLIL::Design::module(RTLIL::IdString name) const
|
||||
{
|
||||
return modules_.count(name) ? modules_.at(name) : NULL;
|
||||
}
|
||||
|
|
@ -1488,21 +1488,21 @@ void RTLIL::Design::optimize()
|
|||
it.second.optimize(this);
|
||||
}
|
||||
|
||||
bool RTLIL::Design::selected_module(const RTLIL::IdString& mod_name) const
|
||||
bool RTLIL::Design::selected_module(RTLIL::IdString mod_name) const
|
||||
{
|
||||
if (!selected_active_module.empty() && mod_name != selected_active_module)
|
||||
return false;
|
||||
return selection().selected_module(mod_name);
|
||||
}
|
||||
|
||||
bool RTLIL::Design::selected_whole_module(const RTLIL::IdString& mod_name) const
|
||||
bool RTLIL::Design::selected_whole_module(RTLIL::IdString mod_name) const
|
||||
{
|
||||
if (!selected_active_module.empty() && mod_name != selected_active_module)
|
||||
return false;
|
||||
return selection().selected_whole_module(mod_name);
|
||||
}
|
||||
|
||||
bool RTLIL::Design::selected_member(const RTLIL::IdString& mod_name, const RTLIL::IdString& memb_name) const
|
||||
bool RTLIL::Design::selected_member(RTLIL::IdString mod_name, RTLIL::IdString memb_name) const
|
||||
{
|
||||
if (!selected_active_module.empty() && mod_name != selected_active_module)
|
||||
return false;
|
||||
|
|
@ -1693,7 +1693,7 @@ RTLIL::IdString RTLIL::Module::derive(RTLIL::Design*, const dict<RTLIL::IdString
|
|||
log_error("Module `%s' is used with parameters but is not parametric!\n", id2cstr(name));
|
||||
}
|
||||
|
||||
size_t RTLIL::Module::count_id(const RTLIL::IdString& id)
|
||||
size_t RTLIL::Module::count_id(RTLIL::IdString id)
|
||||
{
|
||||
return wires_.count(id) + memories.count(id) + cells_.count(id) + processes.count(id);
|
||||
}
|
||||
|
|
@ -1718,7 +1718,7 @@ namespace {
|
|||
cell->name.c_str(), cell->type.c_str(), __FILE__, linenr, buf.str().c_str());
|
||||
}
|
||||
|
||||
int param(const RTLIL::IdString& name)
|
||||
int param(RTLIL::IdString name)
|
||||
{
|
||||
auto it = cell->parameters.find(name);
|
||||
if (it == cell->parameters.end())
|
||||
|
|
@ -1727,7 +1727,7 @@ namespace {
|
|||
return it->second.as_int();
|
||||
}
|
||||
|
||||
int param_bool(const RTLIL::IdString& name)
|
||||
int param_bool(RTLIL::IdString name)
|
||||
{
|
||||
int v = param(name);
|
||||
if (GetSize(cell->parameters.at(name)) > 32)
|
||||
|
|
@ -1737,7 +1737,7 @@ namespace {
|
|||
return v;
|
||||
}
|
||||
|
||||
int param_bool(const RTLIL::IdString& name, bool expected)
|
||||
int param_bool(RTLIL::IdString name, bool expected)
|
||||
{
|
||||
int v = param_bool(name);
|
||||
if (v != expected)
|
||||
|
|
@ -1745,20 +1745,20 @@ namespace {
|
|||
return v;
|
||||
}
|
||||
|
||||
void param_bits(const RTLIL::IdString& name, int width)
|
||||
void param_bits(RTLIL::IdString name, int width)
|
||||
{
|
||||
param(name);
|
||||
if (GetSize(cell->parameters.at(name)) != width)
|
||||
error(__LINE__);
|
||||
}
|
||||
|
||||
std::string param_string(const RTLIL::IdString &name)
|
||||
std::string param_string(RTLIL::IdString name)
|
||||
{
|
||||
param(name);
|
||||
return cell->parameters.at(name).decode_string();
|
||||
}
|
||||
|
||||
void port(const RTLIL::IdString& name, int width)
|
||||
void port(RTLIL::IdString name, int width)
|
||||
{
|
||||
auto it = cell->connections_.find(name);
|
||||
if (it == cell->connections_.end())
|
||||
|
|
@ -4366,14 +4366,14 @@ std::map<unsigned int, RTLIL::Cell*> *RTLIL::Cell::get_all_cells(void)
|
|||
}
|
||||
#endif
|
||||
|
||||
bool RTLIL::Cell::hasPort(const RTLIL::IdString& portname) const
|
||||
bool RTLIL::Cell::hasPort(RTLIL::IdString portname) const
|
||||
{
|
||||
return connections_.count(portname) != 0;
|
||||
}
|
||||
|
||||
// bufnorm
|
||||
|
||||
const RTLIL::SigSpec &RTLIL::Cell::getPort(const RTLIL::IdString& portname) const
|
||||
const RTLIL::SigSpec &RTLIL::Cell::getPort(RTLIL::IdString portname) const
|
||||
{
|
||||
return connections_.at(portname);
|
||||
}
|
||||
|
|
@ -4392,7 +4392,7 @@ bool RTLIL::Cell::known() const
|
|||
return false;
|
||||
}
|
||||
|
||||
bool RTLIL::Cell::input(const RTLIL::IdString& portname) const
|
||||
bool RTLIL::Cell::input(RTLIL::IdString portname) const
|
||||
{
|
||||
if (yosys_celltypes.cell_known(type))
|
||||
return yosys_celltypes.cell_input(type, portname);
|
||||
|
|
@ -4404,7 +4404,7 @@ bool RTLIL::Cell::input(const RTLIL::IdString& portname) const
|
|||
return false;
|
||||
}
|
||||
|
||||
bool RTLIL::Cell::output(const RTLIL::IdString& portname) const
|
||||
bool RTLIL::Cell::output(RTLIL::IdString portname) const
|
||||
{
|
||||
if (yosys_celltypes.cell_known(type))
|
||||
return yosys_celltypes.cell_output(type, portname);
|
||||
|
|
@ -4416,7 +4416,7 @@ bool RTLIL::Cell::output(const RTLIL::IdString& portname) const
|
|||
return false;
|
||||
}
|
||||
|
||||
RTLIL::PortDir RTLIL::Cell::port_dir(const RTLIL::IdString& portname) const
|
||||
RTLIL::PortDir RTLIL::Cell::port_dir(RTLIL::IdString portname) const
|
||||
{
|
||||
if (yosys_celltypes.cell_known(type))
|
||||
return yosys_celltypes.cell_port_dir(type, portname);
|
||||
|
|
@ -4432,22 +4432,22 @@ RTLIL::PortDir RTLIL::Cell::port_dir(const RTLIL::IdString& portname) const
|
|||
return PortDir::PD_UNKNOWN;
|
||||
}
|
||||
|
||||
bool RTLIL::Cell::hasParam(const RTLIL::IdString& paramname) const
|
||||
bool RTLIL::Cell::hasParam(RTLIL::IdString paramname) const
|
||||
{
|
||||
return parameters.count(paramname) != 0;
|
||||
}
|
||||
|
||||
void RTLIL::Cell::unsetParam(const RTLIL::IdString& paramname)
|
||||
void RTLIL::Cell::unsetParam(RTLIL::IdString paramname)
|
||||
{
|
||||
parameters.erase(paramname);
|
||||
}
|
||||
|
||||
void RTLIL::Cell::setParam(const RTLIL::IdString& paramname, RTLIL::Const value)
|
||||
void RTLIL::Cell::setParam(RTLIL::IdString paramname, RTLIL::Const value)
|
||||
{
|
||||
parameters[paramname] = std::move(value);
|
||||
}
|
||||
|
||||
const RTLIL::Const &RTLIL::Cell::getParam(const RTLIL::IdString& paramname) const
|
||||
const RTLIL::Const &RTLIL::Cell::getParam(RTLIL::IdString paramname) const
|
||||
{
|
||||
const auto &it = parameters.find(paramname);
|
||||
if (it != parameters.end())
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue