summaryrefslogtreecommitdiff
path: root/kernel
diff options
context:
space:
mode:
authorClifford Wolf <clifford@clifford.at>2014-08-17 02:16:56 +0200
committerClifford Wolf <clifford@clifford.at>2014-08-17 02:16:56 +0200
commitf3326a642178b66ba98b6371245077ff93ffe215 (patch)
tree9743437c2890c4ff6cf90d0b1ee584cfcad6dfa0 /kernel
parentd491fd8c19cddb49d2feed2a873a328825c7b8f4 (diff)
Improved sig.remove2() performance
Diffstat (limited to 'kernel')
-rw-r--r--kernel/rtlil.cc13
1 files changed, 11 insertions, 2 deletions
diff --git a/kernel/rtlil.cc b/kernel/rtlil.cc
index 60c514d1..e4bf4f9f 100644
--- a/kernel/rtlil.cc
+++ b/kernel/rtlil.cc
@@ -2182,14 +2182,23 @@ void RTLIL::SigSpec::remove2(const std::set<RTLIL::SigBit> &pattern, RTLIL::SigS
std::vector<RTLIL::SigBit> new_bits, new_other_bits;
+ new_bits.resize(SIZE(bits_));
+ if (other != NULL)
+ new_other_bits.resize(SIZE(bits_));
+
+ int k = 0;
for (int i = 0; i < SIZE(bits_); i++) {
if (bits_[i].wire != NULL && pattern.count(bits_[i]))
continue;
if (other != NULL)
- new_other_bits.push_back(other->bits_[i]);
- new_bits.push_back(bits_[i]);
+ new_other_bits[k] = other->bits_[i];
+ new_bits[k++] = bits_[i];
}
+ new_bits.resize(k);
+ if (other != NULL)
+ new_other_bits.resize(k);
+
bits_.swap(new_bits);
width_ = SIZE(bits_);