Skip to content

Commit ef5ba2e

Browse files
authored
[NFC] Reserve the number of operands before push_back (#106234)
This reduces the number of allocations inside the loop. Partially addresses #105836
1 parent d0fe52d commit ef5ba2e

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

llvm/lib/IR/ConstantsContext.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -292,6 +292,7 @@ template <class ConstantClass> struct ConstantAggrKeyType {
292292
ConstantAggrKeyType(const ConstantClass *C,
293293
SmallVectorImpl<Constant *> &Storage) {
294294
assert(Storage.empty() && "Expected empty storage");
295+
Storage.reserve(C->getNumOperands());
295296
for (unsigned I = 0, E = C->getNumOperands(); I != E; ++I)
296297
Storage.push_back(C->getOperand(I));
297298
Operands = Storage;

0 commit comments

Comments
 (0)