llvmorg-github-actions[bot] wrote:

<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-clang

Author: Timm Baeder (tbaederr)

<details>
<summary>Changes</summary>

We know the size the vector is going to have in the success case, so reserve 
that.

---
Full diff: https://github.com/llvm/llvm-project/pull/219981.diff


1 Files Affected:

- (modified) clang/lib/AST/ByteCode/Context.cpp (+3-1) 


``````````diff
diff --git a/clang/lib/AST/ByteCode/Context.cpp 
b/clang/lib/AST/ByteCode/Context.cpp
index 75a5b04cdff19..0212574e4accd 100644
--- a/clang/lib/AST/ByteCode/Context.cpp
+++ b/clang/lib/AST/ByteCode/Context.cpp
@@ -672,7 +672,6 @@ const Function *Context::getOrCreateFunction(const 
FunctionDecl *FuncDecl) {
   }
   // Set up argument indices.
   unsigned ParamOffset = 0;
-  llvm::SmallVector<Function::ParamDescriptor> ParamDescriptors;
 
   // If the return is not a primitive, a pointer to the storage where the
   // value is initialized in is passed as the first argument. See 'RVO'
@@ -715,6 +714,9 @@ const Function *Context::getOrCreateFunction(const 
FunctionDecl *FuncDecl) {
 
   // Assign descriptors to all parameters.
   // Composite objects are lowered to pointers.
+  llvm::SmallVector<Function::ParamDescriptor> ParamDescriptors;
+  ParamDescriptors.reserve(FuncDecl->getNumParams());
+
   const auto *FuncProto = FuncDecl->getType()->getAs<FunctionProtoType>();
   unsigned BlockOffset = 0;
   for (auto [ParamIndex, PD] : llvm::enumerate(FuncDecl->parameters())) {

``````````

</details>


https://github.com/llvm/llvm-project/pull/219981
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to