@@ -207,6 +207,7 @@ RTLIL::Const::Const()
207
207
RTLIL::Const::Const (std::string str)
208
208
{
209
209
flags = RTLIL::CONST_FLAG_STRING;
210
+ bits.reserve (str.size () * 8 );
210
211
for (int i = str.size ()-1 ; i >= 0 ; i--) {
211
212
unsigned char ch = str[i];
212
213
for (int j = 0 ; j < 8 ; j++) {
@@ -219,6 +220,7 @@ RTLIL::Const::Const(std::string str)
219
220
RTLIL::Const::Const (int val, int width)
220
221
{
221
222
flags = RTLIL::CONST_FLAG_NONE;
223
+ bits.reserve (width);
222
224
for (int i = 0 ; i < width; i++) {
223
225
bits.push_back ((val & 1 ) != 0 ? State::S1 : State::S0);
224
226
val = val >> 1 ;
@@ -228,20 +230,23 @@ RTLIL::Const::Const(int val, int width)
228
230
RTLIL::Const::Const (RTLIL::State bit, int width)
229
231
{
230
232
flags = RTLIL::CONST_FLAG_NONE;
233
+ bits.reserve (width);
231
234
for (int i = 0 ; i < width; i++)
232
235
bits.push_back (bit);
233
236
}
234
237
235
238
RTLIL::Const::Const (const std::vector<bool > &bits)
236
239
{
237
240
flags = RTLIL::CONST_FLAG_NONE;
241
+ this ->bits .reserve (bits.size ());
238
242
for (const auto &b : bits)
239
243
this ->bits .emplace_back (b ? State::S1 : State::S0);
240
244
}
241
245
242
246
RTLIL::Const::Const (const RTLIL::Const &c)
243
247
{
244
248
flags = c.flags ;
249
+ this ->bits .reserve (c.size ());
245
250
for (const auto &b : c.bits )
246
251
this ->bits .push_back (b);
247
252
}
0 commit comments