diff --git a/ChangeLog b/ChangeLog
index 66e01bbcdc0ba25a5c212d8881671dde67045268..4dc67f4aebb52604d37a9e8b07eb8162c3e3b702 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2007-07-01  David Lawrence Ramsey  <pooka109@gmail.com>
+
+	* chars.c (nstrncasecmp, mbstrncasecmp): For efficiency, return
+	zero immediately if s1 and s2 point to the same string.
+
 2007-06-30  David Lawrence Ramsey  <pooka109@gmail.com>
 
 	* prompt.c (do_yesno_prompt): Remove redundant check for
diff --git a/src/chars.c b/src/chars.c
index 85ea80a4e7c14bc7a43ee542e93fd19fb09e1243..9a79065a8eac45b8fbaefe4224def478224f604c 100644
--- a/src/chars.c
+++ b/src/chars.c
@@ -506,6 +506,9 @@ int mbstrcasecmp(const char *s1, const char *s2)
 /* This function is equivalent to strncasecmp(). */
 int nstrncasecmp(const char *s1, const char *s2, size_t n)
 {
+    if (s1 == s2)
+	return 0;
+
     assert(s1 != NULL && s2 != NULL);
 
     for (; *s1 != '\0' && *s2 != '\0' && n > 0; s1++, s2++, n--) {
@@ -526,6 +529,9 @@ int mbstrncasecmp(const char *s1, const char *s2, size_t n)
 	char *s1_mb, *s2_mb;
 	wchar_t ws1, ws2;
 
+	if (s1 == s2)
+	    return 0;
+
 	assert(s1 != NULL && s2 != NULL);
 
 	s1_mb = charalloc(MB_CUR_MAX);