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

via llvm-commits llvm-commits at lists.llvm.org
Wed Aug 14 09:40:34 PDT 2024


Author: Kazu Hirata
Date: 2024-08-14T09:40:30-07:00
New Revision: d2f0d991943a9bbf2452adcb11e9a12d5843952b

URL: https://github.com/llvm/llvm-project/commit/d2f0d991943a9bbf2452adcb11e9a12d5843952b
DIFF: https://github.com/llvm/llvm-project/commit/d2f0d991943a9bbf2452adcb11e9a12d5843952b.diff

LOG: [TextAPI] Use range-based for loops (NFC) (#103530)

Added: 
    

Modified: 
    llvm/lib/TextAPI/RecordsSlice.cpp

Removed: 
    


################################################################################
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