avoid unnecessary reallocations in GetOperandConstants (#4708)

reserve capacity since we know the size exactly
This commit is contained in:
pd-valve 2022-02-10 10:31:24 -08:00 committed by GitHub
parent 44923beb52
commit 940127a77d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -158,6 +158,7 @@ Type* ConstantManager::GetType(const Instruction* inst) const {
std::vector<const Constant*> ConstantManager::GetOperandConstants(
const Instruction* inst) const {
std::vector<const Constant*> constants;
constants.reserve(inst->NumInOperands());
for (uint32_t i = 0; i < inst->NumInOperands(); i++) {
const Operand* operand = &inst->GetInOperand(i);
if (operand->type != SPV_OPERAND_TYPE_ID) {