changeset 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 19a848d76372
children e2ff6f156917
files src/protocols/oscar/oscar.c src/protocols/oscar/util.c
diffstat 2 files changed, 13 insertions(+), 28 deletions(-) [+]
line wrap: on
line diff
--- a/src/protocols/oscar/oscar.c	Sun Jun 01 04:11:24 2003 +0000
+++ b/src/protocols/oscar/oscar.c	Sun Jun 01 04:15:46 2003 +0000
@@ -291,13 +291,6 @@
 /* prpl actions - remove this at some point */
 static void oscar_set_info(GaimConnection *gc, char *text);
 
-int ill_just_write_my_own_damn_round_function(double val) {
-	if ((val - (int)val) > 0.5)
-		return val+1;
-	else
-		return val;
-}
-
 static void gaim_free_name_data(struct name_data *data) {
 	g_free(data->name);
 	g_free(data->nick);
@@ -1841,7 +1834,7 @@
 		free(b16);
 	}
 
-	serv_got_update(gc, info->sn, 1, ill_just_write_my_own_damn_round_function(info->warnlevel/10.0), signon, time_idle, type);
+	serv_got_update(gc, info->sn, 1, (info->warnlevel/10.0) + 0.5, signon, time_idle, type);
 
 	return 1;
 }
@@ -3183,7 +3176,7 @@
 			"%s\n"
 			"<hr>\n"),
 			info->sn, images(info->flags),
-			ill_just_write_my_own_damn_round_function(info->warnlevel/10.0),
+			(info->warnlevel/10.0) + 0.5,
 			onlinesince ? onlinesince : "",
 			membersince ? membersince : "",
 			idle ? idle : "");
@@ -3443,7 +3436,7 @@
 	havenewmail = va_arg(ap, int);
 	va_end(ap);
 
-	if (emailinfo) {
+	if (emailinfo && gaim_account_get_check_mail(gc->account)) {
 		gchar *to = g_strdup_printf("%s@%s", gaim_account_get_username(gaim_connection_get_account(gc)), emailinfo->domain);
 		if (emailinfo->unread && havenewmail)
 			gaim_notify_emails(gc, emailinfo->nummsgs, FALSE, NULL, NULL, (const char **)&to, (const char **)&emailinfo->url, NULL, NULL);
@@ -3632,7 +3625,7 @@
 	userinfo = va_arg(ap, aim_userinfo_t *);
 	va_end(ap);
 
-	serv_got_eviled(gc, (userinfo && userinfo->sn[0]) ? userinfo->sn : NULL, ill_just_write_my_own_damn_round_function(newevil/10.0));
+	serv_got_eviled(gc, (userinfo && userinfo->sn[0]) ? userinfo->sn : NULL, (newevil/10.0) + 0.5);
 
 	return 1;
 }
@@ -3646,7 +3639,7 @@
 	info = va_arg(ap, aim_userinfo_t *);
 	va_end(ap);
 
-	gc->evil = ill_just_write_my_own_damn_round_function(info->warnlevel/10.0);
+	gc->evil = (info->warnlevel/10.0) + 0.5;
 
 	if (info->onlinesince)
 		gc->login_time_official = info->onlinesince;
--- 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.