Bug 1427025 - Remove nsCRT::memmem. r=froydnj
authorVenkatesh Pitta <venkateshpitta@gmail.com>
Tue, 10 Apr 2018 04:47:52 +1000
changeset 412480 e9bbfe8e4ba8
parent 412479 bf2262b6aca8
child 412481 23f60e5acaa2
push id101931
push userapavel@mozilla.com
push dateTue, 10 Apr 2018 00:50:11 +0000
treeherdermozilla-inbound@e9bbfe8e4ba8 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersfroydnj
bugs1427025
milestone61.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1427025 - Remove nsCRT::memmem. r=froydnj
xpcom/ds/nsCRT.cpp
xpcom/ds/nsCRT.h
--- a/xpcom/ds/nsCRT.cpp
+++ b/xpcom/ds/nsCRT.cpp
@@ -106,41 +106,16 @@ nsCRT::strcmp(const char16_t* aStr1, con
     }
     if (aStr2) {  // aStr1 must have been null
       return 1;
     }
   }
   return 0;
 }
 
-const char*
-nsCRT::memmem(const char* aHaystack, uint32_t aHaystackLen,
-              const char* aNeedle, uint32_t aNeedleLen)
-{
-  // Sanity checking
-  if (!(aHaystack && aNeedle && aHaystackLen && aNeedleLen &&
-        aNeedleLen <= aHaystackLen)) {
-    return nullptr;
-  }
-
-#ifdef HAVE_MEMMEM
-  return (const char*)::memmem(aHaystack, aHaystackLen, aNeedle, aNeedleLen);
-#else
-  // No memmem means we need to roll our own.  This isn't really optimized
-  // for performance ... if that becomes an issue we can take some inspiration
-  // from the js string compare code in jsstr.cpp
-  for (uint32_t i = 0; i < aHaystackLen - aNeedleLen; i++) {
-    if (!memcmp(aHaystack + i, aNeedle, aNeedleLen)) {
-      return aHaystack + i;
-    }
-  }
-#endif
-  return nullptr;
-}
-
 // This should use NSPR but NSPR isn't exporting its PR_strtoll function
 // Until then...
 int64_t
 nsCRT::atoll(const char* aStr)
 {
   if (!aStr) {
     return 0;
   }
--- a/xpcom/ds/nsCRT.h
+++ b/xpcom/ds/nsCRT.h
@@ -80,22 +80,16 @@ public:
     * WARNING - STRTOK WHACKS str THE FIRST TIME IT IS CALLED *
     * MAKE A COPY OF str IF YOU NEED TO USE IT AFTER strtok() *
   */
   static char* strtok(char* aStr, const char* aDelims, char** aNewStr);
 
   /// Like strcmp except for ucs2 strings
   static int32_t strcmp(const char16_t* aStr1, const char16_t* aStr2);
 
-  // The GNU libc has memmem, which is strstr except for binary data
-  // This is our own implementation that uses memmem on platforms
-  // where it's available.
-  static const char* memmem(const char* aHaystack, uint32_t aHaystackLen,
-                            const char* aNeedle, uint32_t aNeedleLen);
-
   // String to longlong
   static int64_t atoll(const char* aStr);
 
   static char ToUpper(char aChar) { return NS_ToUpper(aChar); }
   static char ToLower(char aChar) { return NS_ToLower(aChar); }
 
   static bool IsUpper(char aChar) { return NS_IsUpper(aChar); }
   static bool IsLower(char aChar) { return NS_IsLower(aChar); }