diff options
author | whitequark <whitequark@whitequark.org> | 2020-05-28 09:41:17 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-05-28 09:41:17 +0000 |
commit | 02bb52eef12113ef638b15b2b0fa922323ab8be3 (patch) | |
tree | bd0f22181ee5af379c415b9177f2d1c211a387c9 /kernel/rtlil.h | |
parent | fdca785eda0ba3d9efd4c2a82539d0f98853e5a5 (diff) | |
parent | 7ff306ccdb47415e3a483adad87076327399434f (diff) | |
download | yosys-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/rtlil.h')
-rw-r--r-- | kernel/rtlil.h | 10 |
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_); } |