adium 5191:321f3e9bbffe: Some tweaks that might speed up the eve...

commits at adium.im commits at adium.im
Tue Oct 23 23:00:25 UTC 2012


details:	http://hg.adium.im/adium/rev/321f3e9bbffe
revision:	5191:321f3e9bbffe
branch:		(none)
author:		Thijs Alkemade <thijsalkemade at gmail.com>
date:		Wed Oct 24 01:00:17 2012 +0200

Some tweaks that might speed up the event loop.

diffs (47 lines):

diff -r 28f09454d13a -r 321f3e9bbffe Plugins/Purple Service/adiumPurpleEventloop.m
--- a/Plugins/Purple Service/adiumPurpleEventloop.m	Wed Oct 24 00:51:42 2012 +0200
+++ b/Plugins/Purple Service/adiumPurpleEventloop.m	Wed Oct 24 01:00:17 2012 +0200
@@ -87,6 +87,11 @@
  */
 guint addTimer(uint64_t interval, uint64_t leeway, GSourceFunc function, gpointer data)
 {
+	if (!function) {
+		NSLog(@"addTimer INVALID: function is NULL, nothing to do; returning tag %i",sourceId+1);
+		return ++sourceId;
+	}
+	
 	dispatch_source_t src;
 	guint tag;
 	
@@ -101,8 +106,8 @@
     dispatch_source_set_event_handler(src, ^{
 		@autoreleasepool {
 
-			if (sourceForTag(tag)) {
-				if (!function || !function(data)) {
+			if (__builtin_expect(sourceForTag(tag) != NULL, 1)) {
+				if (!function(data)) {
 					adium_timeout_remove(tag);
 				}
 			} else {
@@ -135,6 +140,11 @@
 		NSLog(@"INVALID: fd was %i; returning tag %i",fd,sourceId+1);
 		return ++sourceId;
 	}
+	
+	if (!func) {
+		NSLog(@"adium_input_add INVALID: func is NULL, nothing to do; returning tag %i",sourceId+1);
+		return ++sourceId;
+	}
 
 	dispatch_source_t src;
 	guint tag;
@@ -152,7 +162,7 @@
 	
     dispatch_source_set_event_handler(src, ^{
 		@autoreleasepool {
-			if (func) func(user_data, fd, condition);
+			func(user_data, fd, condition);
 		}
     });
 		




More information about the commits mailing list