diff --git a/string/strcasestr.c b/string/strcasestr.c
index 5909fe3cdba88e476c7a989a020f3611bbfeb1de..1f6b7b846f81d0d8fe77b390062d2d86be11b056 100644
--- a/string/strcasestr.c
+++ b/string/strcasestr.c
@@ -58,31 +58,22 @@
Â Â Â  case-insensitive comparison.Â  This function gives unspecified
Â Â Â  results in multibyte locales.Â  */
Â char *
-STRCASESTR (const char *haystack_start, const char *needle_start)
+STRCASESTR (const char *haystack, const char *needle)
Â {
-Â  const char *haystack = haystack_start;
-Â  const char *needle = needle_start;
Â Â  size_t needle_len; /* Length of NEEDLE.Â  */
Â Â  size_t haystack_len; /* Known minimum length of HAYSTACK.Â  */
-Â  bool ok = true; /* True if NEEDLE is prefix of HAYSTACK.Â  */
-
-Â  /* Determine length of NEEDLE, and in the process, make sure
-Â Â Â Â  HAYSTACK is at least as long (no point processing all of a long
-Â Â Â Â  NEEDLE if HAYSTACK is too short).Â  */
-Â  while (*haystack && *needle)
-Â Â Â  {
-Â Â Â Â Â  ok &= (TOLOWER ((unsigned char) *haystack)
-Â Â Â Â Â Â Â Â Â Â Â  == TOLOWER ((unsigned char) *needle));
-Â Â Â Â Â  haystack++;
-Â Â Â Â Â  needle++;
-Â Â Â  }
-Â  if (*needle)
+
+Â  /* Handle empty NEEDLE special case.Â  */
+Â  if (needle[0] == '\0')
+Â Â Â  return (char *) haystack;
+
+Â  /* Ensure HAYSTACK length is at least as long as NEEDLE length.
+Â Â Â Â  Since a match may occur early on in a huge HAYSTACK, use strnlen
+Â Â Â Â  and read ahead a few cachelines for improved performance.Â  */
+Â  needle_len = strlen (needle);
+Â  haystack_len = __strnlen (haystack, needle_len + 256);
+Â  if (haystack_len < needle_len)
Â Â Â Â  return NULL;
-Â  if (ok)
-Â Â Â  return (char *) haystack_start;
-Â  needle_len = needle - needle_start;
-Â  haystack = haystack_start + 1;
-Â  haystack_len = needle_len - 1;
Â 
Â Â  /* Perform the search.Â  Abstract memory is considered to be an array
Â Â Â Â Â  of 'unsigned char' values, not an array of 'char' values.Â  See
@@ -90,10 +81,10 @@ STRCASESTR (const char *haystack_start, const char *needle_start)
Â Â  if (needle_len < LONG_NEEDLE_THRESHOLD)
Â Â Â Â  return two_way_short_needle ((const unsigned char *) haystack,
Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â  haystack_len,
-Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â  (const unsigned char *) needle_start,
+Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â  (const unsigned char *) needle,
Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â  needle_len);
Â Â  return two_way_long_needle ((const unsigned char *) haystack, haystack_len,
-Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â  (const unsigned char *) needle_start,
+Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â  (const unsigned char *) needle,
Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â  needle_len);
Â }
Â 
diff --git a/string/strstr.c b/string/strstr.c
index 265e9f310ce507ce63740cc42d8ceea1d28dab01..33acdc5442d3e9031298a56e4f52a19e2ffa7d84 100644
--- a/string/strstr.c
+++ b/string/strstr.c
@@ -50,33 +50,32 @@
Â Â Â  if NEEDLE is empty, otherwise NULL if NEEDLE is not found in
Â Â Â  HAYSTACK.Â  */
Â char *
-STRSTR (const char *haystack_start, const char *needle_start)
+STRSTR (const char *haystack, const char *needle)
Â {
-Â  const char *haystack = haystack_start;
-Â  const char *needle = needle_start;
Â Â  size_t needle_len; /* Length of NEEDLE.Â  */
Â Â  size_t haystack_len; /* Known minimum length of HAYSTACK.Â  */
-Â  bool ok = true; /* True if NEEDLE is prefix of HAYSTACK.Â  */
-
-Â  /* Determine length of NEEDLE, and in the process, make sure
-Â Â Â Â  HAYSTACK is at least as long (no point processing all of a long
-Â Â Â Â  NEEDLE if HAYSTACK is too short).Â  */
-Â  while (*haystack && *needle)
-Â Â Â  ok &= *haystack++ == *needle++;
-Â  if (*needle)
+
+Â  /* Handle empty NEEDLE special case.Â  */
+Â  if (needle[0] == '\0')
+Â Â Â  return (char *) haystack;
+
+Â  /* Skip until we find the first matching char from NEEDLE.Â  */
+Â  haystack = strchr (haystack, needle[0]);
+Â  if (haystack == NULL || needle[1] == '\0')
+Â Â Â  return (char *) haystack;
+
+Â  /* Ensure HAYSTACK length is at least as long as NEEDLE length.
+Â Â Â Â  Since a match may occur early on in a huge HAYSTACK, use strnlen
+Â Â Â Â  and read ahead a few cachelines for improved performance.Â  */
+Â  needle_len = strlen (needle);
+Â  haystack_len = __strnlen (haystack, needle_len + 256);
+Â  if (haystack_len < needle_len)
Â Â Â Â  return NULL;
-Â  if (ok)
-Â Â Â  return (char *) haystack_start;
-
-Â  /* Reduce the size of haystack using strchr, since it has a smaller
-Â Â Â Â  linear coefficient than the Two-Way algorithm.Â  */
-Â  needle_len = needle - needle_start;
-Â  haystack = strchr (haystack_start + 1, *needle_start);
-Â  if (!haystack || __builtin_expect (needle_len == 1, 0))
+
+Â  /* Check whether we have a match.Â  This improves performance since we avoid
+Â Â Â Â  the initialization overhead of the two-way algorithm.Â  */
+Â  if (memcmp (haystack, needle, needle_len) == 0)
Â Â Â Â  return (char *) haystack;
-Â  needle -= needle_len;
-Â  haystack_len = (haystack > haystack_start + needle_len ? 1
-Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â  : needle_len + haystack_start - haystack);
Â 
Â Â  /* Perform the search.Â  Abstract memory is considered to be an array
Â Â Â Â Â  of 'unsigned char' values, not an array of 'char' values.Â  See
