changeset 29323:d7cc8dbf91f0

We don't need to keep the delta in memory. We keep the actual time of the last message. Saves 20 bytes of memory.
author Mark Doliner <mark@kingant.net>
date Tue, 02 Feb 2010 23:11:35 +0000
parents 816e9b5f3310
children da49e136fb34
files libpurple/protocols/oscar/family_oservice.c libpurple/protocols/oscar/oscar.h
diffstat 2 files changed, 17 insertions(+), 39 deletions(-) [+]
line wrap: on
line diff
--- a/libpurple/protocols/oscar/family_oservice.c	Tue Feb 02 22:56:17 2010 +0000
+++ b/libpurple/protocols/oscar/family_oservice.c	Tue Feb 02 23:11:35 2010 +0000
@@ -334,30 +334,16 @@
 		rateclass->current = byte_stream_get32(bs);
 		rateclass->max = byte_stream_get32(bs);
 
-		/*
-		 * The server will send an extra five bytes of parameters
-		 * depending on the version we advertised in 1/17.  If we
-		 * didn't send 1/17 (evil!), then this will crash and you
-		 * die, as it will default to the old version but we have
-		 * the new version hardcoded here.
-		 */
-		if (mod->version >= 3)
-		{
-			rateclass->delta = byte_stream_get32(bs);
+		if (mod->version >= 3) {
+			delta = byte_stream_get32(bs);
 			rateclass->dropping_snacs = byte_stream_get8(bs);
-
-			delta = rateclass->delta;
-
-			rateclass->last.tv_sec = now.tv_sec - delta / 1000;
-			delta %= 1000;
-			rateclass->last.tv_usec = now.tv_usec - delta * 1000;
+		} else {
+			delta = 0;
+			rateclass->dropping_snacs = 0;
 		}
-		else
-		{
-			rateclass->delta = rateclass->dropping_snacs = 0;
-			rateclass->last.tv_sec = now.tv_sec;
-			rateclass->last.tv_usec = now.tv_usec;
-		}
+		rateclass->last.tv_sec = now.tv_sec - delta / 1000;
+		delta %= 1000;
+		rateclass->last.tv_usec = now.tv_usec - delta * 1000;
 
 		rateclass->members = g_hash_table_new(g_direct_hash, g_direct_equal);
 		conn->rateclasses = g_slist_prepend(conn->rateclasses, rateclass);
@@ -486,28 +472,21 @@
 	rateclass->current = byte_stream_get32(bs);
 	rateclass->max = byte_stream_get32(bs);
 
-	if (mod->version >= 3)
-	{
-		rateclass->delta = byte_stream_get32(bs);
+	if (mod->version >= 3) {
+		delta = byte_stream_get32(bs);
 		rateclass->dropping_snacs = byte_stream_get8(bs);
-
-		delta = rateclass->delta;
-
-		rateclass->last.tv_sec = now.tv_sec - delta / 1000;
-		delta %= 1000;
-		rateclass->last.tv_usec = now.tv_usec - delta * 1000;
+	} else {
+		delta = 0;
+		rateclass->dropping_snacs = 0;
 	}
-	else
-	{
-		rateclass->delta = rateclass->dropping_snacs = 0;
-		rateclass->last.tv_sec = now.tv_sec;
-		rateclass->last.tv_usec = now.tv_usec;
-	}
+	rateclass->last.tv_sec = now.tv_sec - delta / 1000;
+	delta %= 1000;
+	rateclass->last.tv_usec = now.tv_usec - delta * 1000;
 
 	if ((userfunc = aim_callhandler(od, snac->family, snac->subtype))) {
 		/* Can't pass in guint8 via ... varargs, so we use an unsigned int */
 		unsigned int dropping_snacs = rateclass->dropping_snacs;
-		ret = userfunc(od, conn, frame, code, classid, rateclass->windowsize, rateclass->clear, rateclass->alert, rateclass->limit, rateclass->disconnect, rateclass->current, rateclass->max, rateclass->delta, dropping_snacs);
+		ret = userfunc(od, conn, frame, code, classid, rateclass->windowsize, rateclass->clear, rateclass->alert, rateclass->limit, rateclass->disconnect, rateclass->current, rateclass->max, delta, dropping_snacs);
 	}
 
 	return ret;
--- a/libpurple/protocols/oscar/oscar.h	Tue Feb 02 22:56:17 2010 +0000
+++ b/libpurple/protocols/oscar/oscar.h	Tue Feb 02 23:11:35 2010 +0000
@@ -1685,7 +1685,6 @@
 	guint32 disconnect;
 	guint32 current;
 	guint32 max;
-	guint32 delta;
 	guint8 dropping_snacs;
 	GHashTable *members; /* Key is family and subtype, value is TRUE. */