aboutsummaryrefslogtreecommitdiffstats
path: root/kernel
diff options
context:
space:
mode:
authorwhitequark <whitequark@whitequark.org>2020-05-28 09:41:17 +0000
committerGitHub <noreply@github.com>2020-05-28 09:41:17 +0000
commit02bb52eef12113ef638b15b2b0fa922323ab8be3 (patch)
treebd0f22181ee5af379c415b9177f2d1c211a387c9 /kernel
parentfdca785eda0ba3d9efd4c2a82539d0f98853e5a5 (diff)
parent7ff306ccdb47415e3a483adad87076327399434f (diff)
downloadyosys-02bb52eef12113ef638b15b2b0fa922323ab8be3.tar.gz
yosys-02bb52eef12113ef638b15b2b0fa922323ab8be3.tar.bz2
yosys-02bb52eef12113ef638b15b2b0fa922323ab8be3.zip
Merge pull request #2088 from rswarbrick/count-at
Minor optimisation in Module::wire() and Module::cell()
Diffstat (limited to 'kernel')
-rw-r--r--kernel/rtlil.h10
1 files changed, 8 insertions, 2 deletions
diff --git a/kernel/rtlil.h b/kernel/rtlil.h
index 96b10bbd6..423c0b4bd 100644
--- a/kernel/rtlil.h
+++ b/kernel/rtlil.h
@@ -1134,8 +1134,14 @@ public:
return design->selected_member(name, member->name);
}
- RTLIL::Wire* wire(RTLIL::IdString id) { return wires_.count(id) ? wires_.at(id) : nullptr; }
- RTLIL::Cell* cell(RTLIL::IdString id) { return cells_.count(id) ? cells_.at(id) : nullptr; }
+ RTLIL::Wire* wire(RTLIL::IdString id) {
+ auto it = wires_.find(id);
+ return it == wires_.end() ? nullptr : it->second;
+ }
+ RTLIL::Cell* cell(RTLIL::IdString id) {
+ auto it = cells_.find(id);
+ return it == cells_.end() ? nullptr : it->second;
+ }
RTLIL::ObjRange<RTLIL::Wire*> wires() { return RTLIL::ObjRange<RTLIL::Wire*>(&wires_, &refcount_wires_); }
RTLIL::ObjRange<RTLIL::Cell*> cells() { return RTLIL::ObjRange<RTLIL::Cell*>(&cells_, &refcount_cells_); }