https://github.com/tbaederr created 
https://github.com/llvm/llvm-project/pull/219981

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

>From 972b74c0d02e6c017e16fd53a67c2c12d44dd822 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Timm=20B=C3=A4der?= <[email protected]>
Date: Mon, 31 Aug 2026 16:06:11 +0200
Subject: [PATCH] [clang][bytecode][NFC] reserve() ParamDescriptors

We know the size the vector is going to have in the success case, so
reserve that.
---
 clang/lib/AST/ByteCode/Context.cpp | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

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())) {

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

Reply via email to