[llvm] bd08a87 - [EHStreamer] Simplify sharedTypeIDs with std::mismatch

Fangrui Song via llvm-commits llvm-commits at lists.llvm.org
Mon Sep 28 15:06:09 PDT 2020


Author: Fangrui Song
Date: 2020-09-28T15:05:59-07:00
New Revision: bd08a87cfede308f040d79b45245213afd87959a

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

LOG: [EHStreamer] Simplify sharedTypeIDs with std::mismatch

(Note that EMStreamer.cpp is largely under tested. The only test checking the prefix sharing is CodeGen/WebAssembly/eh-lsda.ll)

Added: 
    

Modified: 
    llvm/lib/CodeGen/AsmPrinter/EHStreamer.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/CodeGen/AsmPrinter/EHStreamer.cpp b/llvm/lib/CodeGen/AsmPrinter/EHStreamer.cpp
index c0f32208ef72..0691c8bf1078 100644
--- a/llvm/lib/CodeGen/AsmPrinter/EHStreamer.cpp
+++ b/llvm/lib/CodeGen/AsmPrinter/EHStreamer.cpp
@@ -44,15 +44,9 @@ EHStreamer::~EHStreamer() = default;
 unsigned EHStreamer::sharedTypeIDs(const LandingPadInfo *L,
                                    const LandingPadInfo *R) {
   const std::vector<int> &LIds = L->TypeIds, &RIds = R->TypeIds;
-  unsigned LSize = LIds.size(), RSize = RIds.size();
-  unsigned MinSize = LSize < RSize ? LSize : RSize;
-  unsigned Count = 0;
-
-  for (; Count != MinSize; ++Count)
-    if (LIds[Count] != RIds[Count])
-      return Count;
-
-  return Count;
+  return std::mismatch(LIds.begin(), LIds.end(), RIds.begin(), RIds.end())
+             .first -
+         LIds.begin();
 }
 
 /// Compute the actions table and gather the first action index for each landing


        


More information about the llvm-commits mailing list