Bug 1427025 - Remove nsCRT::memmem. r=froydnj

This commit is contained in:
Venkatesh Pitta 2018-04-10 04:47:52 +10:00
parent 73071eec8f
commit 2c25ef1a1c
2 changed files with 0 additions and 31 deletions

View File

@ -111,31 +111,6 @@ nsCRT::strcmp(const char16_t* aStr1, const char16_t* aStr2)
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

View File

@ -85,12 +85,6 @@ public:
/// 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);