[clang] 61f09bc - [clang-format] Use llvm::seq instead of std::iota. NFC.

Marek Kurdej via cfe-commits cfe-commits at lists.llvm.org
Wed Feb 2 05:02:24 PST 2022


Author: Marek Kurdej
Date: 2022-02-02T14:00:50+01:00
New Revision: 61f09bcf11dee028ba47f4756910b25b043505e1

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

LOG: [clang-format] Use llvm::seq instead of std::iota. NFC.

Added: 
    

Modified: 
    clang/lib/Format/Format.cpp

Removed: 
    


################################################################################
diff  --git a/clang/lib/Format/Format.cpp b/clang/lib/Format/Format.cpp
index d9952f5d5d6d9..3abe569f8770a 100644
--- a/clang/lib/Format/Format.cpp
+++ b/clang/lib/Format/Format.cpp
@@ -34,6 +34,7 @@
 #include "clang/Lex/Lexer.h"
 #include "clang/Tooling/Inclusions/HeaderIncludes.h"
 #include "llvm/ADT/STLExtras.h"
+#include "llvm/ADT/Sequence.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Support/Allocator.h"
 #include "llvm/Support/Debug.h"
@@ -44,7 +45,6 @@
 #include <algorithm>
 #include <memory>
 #include <mutex>
-#include <numeric>
 #include <string>
 #include <unordered_map>
 
@@ -2521,9 +2521,8 @@ static void sortCppIncludes(const FormatStyle &Style,
   unsigned IncludesBlockSize = IncludesEndOffset - IncludesBeginOffset;
   if (!affectsRange(Ranges, IncludesBeginOffset, IncludesEndOffset))
     return;
-  SmallVector<unsigned, 16> Indices;
-  Indices.resize(Includes.size());
-  std::iota(Indices.begin(), Indices.end(), 0);
+  SmallVector<unsigned, 16> Indices =
+      llvm::to_vector<16>(llvm::seq<unsigned>(0, Includes.size()));
 
   if (Style.SortIncludes == FormatStyle::SI_CaseInsensitive) {
     llvm::stable_sort(Indices, [&](unsigned LHSI, unsigned RHSI) {
@@ -2750,10 +2749,8 @@ static void sortJavaImports(const FormatStyle &Style,
   if (!affectsRange(Ranges, ImportsBeginOffset, ImportsEndOffset))
     return;
 
-  SmallVector<unsigned, 16> Indices;
-  Indices.resize(Imports.size());
-  std::iota(Indices.begin(), Indices.end(), 0);
-
+  SmallVector<unsigned, 16> Indices =
+      llvm::to_vector<16>(llvm::seq<unsigned>(0, Imports.size()));
   SmallVector<unsigned, 16> JavaImportGroups;
   JavaImportGroups.reserve(Imports.size());
   for (const JavaImportDirective &Import : Imports)


        


More information about the cfe-commits mailing list