[PATCH] D124840: [RFC] Add and sort decl to maintain order instead of inserting in order

Ivan Murashko via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue May 3 09:10:02 PDT 2022


This revision was automatically updated to reflect the committed changes.
Closed by commit rG2deebc0048f9: [RFC] Add and sort decl to maintain order instead of inserting in order (authored by kuganv, committed by ivanmurashko).
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D124840/new/

https://reviews.llvm.org/D124840

Files:
  clang/lib/Serialization/ASTWriter.cpp


Index: clang/lib/Serialization/ASTWriter.cpp
===================================================================
--- clang/lib/Serialization/ASTWriter.cpp
+++ clang/lib/Serialization/ASTWriter.cpp
@@ -3114,6 +3114,7 @@
   for (auto &FileDeclEntry : SortedFileDeclIDs) {
     DeclIDInFileInfo &Info = *FileDeclEntry.second;
     Info.FirstDeclIndex = FileGroupedDeclIDs.size();
+    llvm::stable_sort(Info.DeclIDs);
     for (auto &LocDeclEntry : Info.DeclIDs)
       FileGroupedDeclIDs.push_back(LocDeclEntry.second);
   }
@@ -5462,16 +5463,7 @@
 
   std::pair<unsigned, serialization::DeclID> LocDecl(Offset, ID);
   LocDeclIDsTy &Decls = Info->DeclIDs;
-
-  if (Decls.empty() || Decls.back().first <= Offset) {
-    Decls.push_back(LocDecl);
-    return;
-  }
-
-  LocDeclIDsTy::iterator I =
-      llvm::upper_bound(Decls, LocDecl, llvm::less_first());
-
-  Decls.insert(I, LocDecl);
+  Decls.push_back(LocDecl);
 }
 
 unsigned ASTWriter::getAnonymousDeclarationNumber(const NamedDecl *D) {


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D124840.426738.patch
Type: text/x-patch
Size: 994 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20220503/e8b6e0c8/attachment.bin>


More information about the cfe-commits mailing list