unsigned ImportsBlockSize = ImportsEndOffset - ImportsBeginOffset;
if (!affectsRange(Ranges, ImportsBeginOffset, ImportsEndOffset))
return;
+
SmallVector<unsigned, 16> Indices;
+ Indices.resize(Imports.size());
+ std::iota(Indices.begin(), Indices.end(), 0);
+
SmallVector<unsigned, 16> JavaImportGroups;
- for (unsigned i = 0, e = Imports.size(); i != e; ++i) {
- Indices.push_back(i);
- JavaImportGroups.push_back(
- findJavaImportGroup(Style, Imports[i].Identifier));
- }
+ JavaImportGroups.reserve(Imports.size());
+ for (const JavaImportDirective &Import : Imports)
+ JavaImportGroups.push_back(findJavaImportGroup(Style, Import.Identifier));
+
bool StaticImportAfterNormalImport =
Style.SortJavaStaticImport == FormatStyle::SJSIO_After;
llvm::sort(Indices, [&](unsigned LHSI, unsigned RHSI) {