diff --git a/xls/jit/ir_builder_visitor.cc b/xls/jit/ir_builder_visitor.cc index 5dad0c9a6f..0bd13540be 100644 --- a/xls/jit/ir_builder_visitor.cc +++ b/xls/jit/ir_builder_visitor.cc @@ -2238,6 +2238,7 @@ absl::Status IrBuilderVisitor::HandleInvoke(Invoke* invoke) { llvm::Value* output_buffer = node_context.GetOutputPtr(0); std::vector operand_ptrs; + operand_ptrs.reserve(invoke->operand_count()); for (int64_t i = 0; i < invoke->operand_count(); ++i) { operand_ptrs.push_back(node_context.GetOperandPtr(i)); } @@ -3043,6 +3044,7 @@ absl::Status IrBuilderVisitor::HandleNaryOp( NewNodeIrContext(node, NumberedStrings("operand", node->operand_count()))); std::vector args; + args.reserve(node->operand_count()); for (int64_t i = 0; i < node->operand_count(); ++i) { args.push_back(node_context.LoadOperand(i)); } diff --git a/xls/jit/type_layout.cc b/xls/jit/type_layout.cc index 8b9082e703..3acf1dcf37 100644 --- a/xls/jit/type_layout.cc +++ b/xls/jit/type_layout.cc @@ -127,6 +127,7 @@ Value TypeLayout::NativeLayoutToValueInternal(Type* element_type, if (element_type->IsTuple()) { TupleType* tuple_type = element_type->AsTupleOrDie(); std::vector elements; + elements.reserve(tuple_type->size()); for (int64_t i = 0; i < tuple_type->size(); ++i) { elements.push_back(NativeLayoutToValueInternal( tuple_type->element_type(i), buffer, leaf_index)); @@ -137,6 +138,7 @@ Value TypeLayout::NativeLayoutToValueInternal(Type* element_type, CHECK(element_type->IsArray()); ArrayType* array_type = element_type->AsArrayOrDie(); std::vector elements; + elements.reserve(array_type->size()); for (int64_t i = 0; i < array_type->size(); ++i) { elements.push_back(NativeLayoutToValueInternal(array_type->element_type(), buffer, leaf_index));