[PATCH 2/9] Xext: localise use of IdleTimeCounter

Peter Hutterer peter.hutterer at who-t.net
Tue Mar 13 22:47:19 PDT 2012


Instead of referring to the global IdleTimeCounter everywhere, only do it
once and use a local variable for the rest.

Cleanup for future features, no functional changes.

Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
---
 Xext/sync.c |   16 +++++++++-------
 1 files changed, 9 insertions(+), 7 deletions(-)

diff --git a/Xext/sync.c b/Xext/sync.c
index 46b9cb8..e97b124 100644
--- a/Xext/sync.c
+++ b/Xext/sync.c
@@ -2744,16 +2744,17 @@ IdleTimeQueryValue (pointer pCounter, CARD64 *pValue_return)
 static void
 IdleTimeBlockHandler(pointer env, struct timeval **wt, pointer LastSelectMask)
 {
+    SyncCounter *counter = IdleTimeCounter;
     XSyncValue idle, old_idle;
-    SyncTriggerList *list = IdleTimeCounter->sync.pTriglist;
+    SyncTriggerList *list = counter->sync.pTriglist;
     SyncTrigger *trig;
 
     if (!pIdleTimeValueLess && !pIdleTimeValueGreater)
 	return;
 
-    old_idle = IdleTimeCounter->value;
+    old_idle = counter->value;
     IdleTimeQueryValue (NULL, &idle);
-    IdleTimeCounter->value = idle; /* push, so CheckTrigger works */
+    counter->value = idle; /* push, so CheckTrigger works */
 
     if (pIdleTimeValueLess &&
         XSyncValueLessOrEqual (idle, *pIdleTimeValueLess))
@@ -2766,7 +2767,7 @@ IdleTimeBlockHandler(pointer env, struct timeval **wt, pointer LastSelectMask)
 	 * immediately so we can reschedule.
 	 */
 
-	for (list = IdleTimeCounter->sync.pTriglist; list; list = list->next) {
+	for (list = counter->sync.pTriglist; list; list = list->next) {
 	    trig = list->pTrigger;
 	    if (trig->CheckTrigger(trig, old_idle)) {
 		AdjustWaitForDelay(wt, 0);
@@ -2800,7 +2801,7 @@ IdleTimeBlockHandler(pointer env, struct timeval **wt, pointer LastSelectMask)
 	                        idle, &overflow);
 	    timeout = min(timeout, XSyncValueLow32 (value));
 	} else {
-	    for (list = IdleTimeCounter->sync.pTriglist; list; list = list->next) {
+	    for (list = counter->sync.pTriglist; list; list = list->next) {
 		trig = list->pTrigger;
 		if (trig->CheckTrigger(trig, old_idle)) {
 		    timeout = min(timeout, 0);
@@ -2812,12 +2813,13 @@ IdleTimeBlockHandler(pointer env, struct timeval **wt, pointer LastSelectMask)
 	AdjustWaitForDelay (wt, timeout);
     }
 
-    IdleTimeCounter->value = old_idle; /* pop */
+    counter->value = old_idle; /* pop */
 }
 
 static void
 IdleTimeWakeupHandler (pointer env, int rc, pointer LastSelectMask)
 {
+    SyncCounter *counter = IdleTimeCounter;
     XSyncValue idle;
 
     if (!pIdleTimeValueLess && !pIdleTimeValueGreater)
@@ -2830,7 +2832,7 @@ IdleTimeWakeupHandler (pointer env, int rc, pointer LastSelectMask)
         (pIdleTimeValueLess &&
 	 XSyncValueLessOrEqual (idle, *pIdleTimeValueLess)))
     {
-	SyncChangeCounter (IdleTimeCounter, idle);
+	SyncChangeCounter (counter, idle);
     }
 }
 
-- 
1.7.7.6



More information about the xorg-devel mailing list