[llvm] [TextAPI] Use range-based for loops (NFC) (PR #103530)

Kazu Hirata via llvm-commits llvm-commits at lists.llvm.org
Tue Aug 13 20:37:37 PDT 2024


https://github.com/kazutakahirata created https://github.com/llvm/llvm-project/pull/103530

None

>From 626be2f90b8dc2cad21d6cb5006a8a18f37dfce5 Mon Sep 17 00:00:00 2001
From: Kazu Hirata <kazu at google.com>
Date: Tue, 13 Aug 2024 20:29:20 -0700
Subject: [PATCH] [TextAPI] Use range-based for loops (NFC)

---
 llvm/lib/TextAPI/RecordsSlice.cpp | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/llvm/lib/TextAPI/RecordsSlice.cpp b/llvm/lib/TextAPI/RecordsSlice.cpp
index 111a1fa6eaf43b..04c48eaa628ea4 100644
--- a/llvm/lib/TextAPI/RecordsSlice.cpp
+++ b/llvm/lib/TextAPI/RecordsSlice.cpp
@@ -243,16 +243,18 @@ ObjCCategoryRecord *RecordsSlice::addObjCCategory(StringRef ClassToExtend,
 
 std::vector<ObjCIVarRecord *> ObjCContainerRecord::getObjCIVars() const {
   std::vector<ObjCIVarRecord *> Records;
-  llvm::for_each(IVars,
-                 [&](auto &Record) { Records.push_back(Record.second.get()); });
+  Records.reserve(IVars.size());
+  for (const auto &Record : IVars)
+    Records.push_back(Record.second.get());
   return Records;
 }
 
 std::vector<ObjCCategoryRecord *>
 ObjCInterfaceRecord::getObjCCategories() const {
   std::vector<ObjCCategoryRecord *> Records;
-  llvm::for_each(Categories,
-                 [&](auto &Record) { Records.push_back(Record.second); });
+  Records.reserve(Categories.size());
+  for (const auto &Record : Categories)
+    Records.push_back(Record.second);
   return Records;
 }
 



More information about the llvm-commits mailing list