TLI: Use lambda. NFC.
authorMichael Zolotukhin <mzolotukhin@apple.com>
Mon, 2 Mar 2015 20:50:08 +0000 (20:50 +0000)
committerMichael Zolotukhin <mzolotukhin@apple.com>
Mon, 2 Mar 2015 20:50:08 +0000 (20:50 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@231011 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Analysis/TargetLibraryInfo.cpp

index 91041fc4b52e740fbf76935ce81efb0f5c3d1349..e1b028e40ff7cafd82d4136cabe11b7c691f1928 100644 (file)
@@ -714,25 +714,6 @@ TargetLibraryInfoImpl &TargetLibraryInfoImpl::operator=(TargetLibraryInfoImpl &&
   return *this;
 }
 
-namespace {
-struct StringComparator {
-  /// Compare two strings and return true if LHS is lexicographically less than
-  /// RHS. Requires that RHS doesn't contain any zero bytes.
-  bool operator()(const char *LHS, StringRef RHS) const {
-    // Compare prefixes with strncmp. If prefixes match we know that LHS is
-    // greater or equal to RHS as RHS can't contain any '\0'.
-    return std::strncmp(LHS, RHS.data(), RHS.size()) < 0;
-  }
-
-  // Provided for compatibility with MSVC's debug mode.
-  bool operator()(StringRef LHS, const char *RHS) const { return LHS < RHS; }
-  bool operator()(StringRef LHS, StringRef RHS) const { return LHS < RHS; }
-  bool operator()(const char *LHS, const char *RHS) const {
-    return std::strcmp(LHS, RHS) < 0;
-  }
-};
-}
-
 bool TargetLibraryInfoImpl::getLibFunc(StringRef funcName,
                                    LibFunc::Func &F) const {
   const char **Start = &StandardNames[0];
@@ -747,7 +728,10 @@ bool TargetLibraryInfoImpl::getLibFunc(StringRef funcName,
   // strip it if present.
   if (funcName.front() == '\01')
     funcName = funcName.substr(1);
-  const char **I = std::lower_bound(Start, End, funcName, StringComparator());
+  const char **I = std::lower_bound(
+      Start, End, funcName, [](const char *LHS, StringRef RHS) {
+        return std::strncmp(LHS, RHS.data(), RHS.size()) < 0;
+      });
   if (I != End && *I == funcName) {
     F = (LibFunc::Func)(I - Start);
     return true;