diff src/protocols/oscar/util.c @ 5628:9a34e950792e

[gaim-migrate @ 6035] Fixes the AIM always notifies you of new mail bug. Improves the performance of aim_sncmp, it should be at least twice as fast now. And this function gets called a lot. It might even be noticable, if your computer is slow. Thanks to Ryan McCabe again for this, he's cool. Removed the round function, as someone in #gaim suggested a better way. committer: Tailor Script <tailor@pidgin.im>
author Mark Doliner <mark@kingant.net>
date Sun, 01 Jun 2003 04:15:46 +0000
parents 8ab1875e6d09
children c4e0b20cf466
line wrap: on
line diff
--- a/src/protocols/oscar/util.c	Sun Jun 01 04:11:24 2003 +0000
+++ b/src/protocols/oscar/util.c	Sun Jun 01 04:15:46 2003 +0000
@@ -187,7 +187,8 @@
 * This takes two screen names and compares them using the rules
 * on screen names for AIM/AOL.  Mainly, this means case and space
 * insensitivity (all case differences and spacing differences are
-* ignored).
+* ignored, with the exception that screen names can not start with 
+* a space).
 *
 * Return: 0 if equal
 *     non-0 if different
@@ -196,27 +197,18 @@
 faim_export int aim_sncmp(const char *sn1, const char *sn2)
 {
 
-	if (aim_snlen(sn1) != aim_snlen(sn2))
-		return 1;
-
-	/* XXX - Should be able to only check if sn1 != '\0', right?  Is that faster? */
-	while ((*sn1 != '\0') && (*sn2 != '\0')) {
+	while (toupper(*sn1) == toupper(*sn2)) {
+		if (*sn1 == '\0')
+			return 0;
+		sn1++;
+		sn2++;
 		while (*sn2 == ' ')
 			*sn2++;
 		while (*sn1 == ' ')
 			*sn1++;
-		if (toupper(*sn1) != toupper(*sn2))
-			return 1;
-		sn1++;
-		sn2++;
 	}
 
-	/* Should both be NULL */
-	/* XXX - I think this check is not necessary, but I'm afeared to take it out */
-	if (*sn1 != *sn2)
-		return 1;
-
-	return 0;
+	return 1;
 }
 
 /* strsep Copyright (C) 1992, 1993 Free Software Foundation, Inc.