[glib: 5/11] tests: Remove unnecessary static attributes from variables



commit 31664e62f93f715dd868097524cad8834961369f
Author: Philip Withnall <withnall endlessm com>
Date:   Wed Feb 27 11:54:42 2019 +0000

    tests: Remove unnecessary static attributes from variables
    
    These functions are not run more than once, so the variables don’t need
    to be static to save state between runs.
    
    Signed-off-by: Philip Withnall <withnall endlessm com>

 gobject/tests/closure-refcount.c | 17 +++++++++--------
 1 file changed, 9 insertions(+), 8 deletions(-)
---
diff --git a/gobject/tests/closure-refcount.c b/gobject/tests/closure-refcount.c
index 941db9b0f..184860b6b 100644
--- a/gobject/tests/closure-refcount.c
+++ b/gobject/tests/closure-refcount.c
@@ -176,11 +176,12 @@ static gpointer
 thread1_main (gpointer data)
 {
   GClosure *closure = data;
-  while (!stopping)
+  guint i = 0;
+
+  for (i = 0; !stopping; i++)
     {
-      static guint count = 0;
       test_closure (closure);
-      if (++count % 10000 == 0)
+      if (i % 10000 == 0)
         {
           g_test_message ("Yielding from thread1");
           g_thread_yield(); /* force context switch */
@@ -194,11 +195,12 @@ static gpointer
 thread2_main (gpointer data)
 {
   GClosure *closure = data;
-  while (!stopping)
+  guint i = 0;
+
+  for (i = 0; !stopping; i++)
     {
-      static guint count = 0;
       test_closure (closure);
-      if (++count % 10000 == 0)
+      if (i % 10000 == 0)
         {
           g_test_message ("Yielding from thread2");
           g_thread_yield(); /* force context switch */
@@ -272,9 +274,8 @@ test_closure_refcount (void)
   for (i = 0; i < 1000000; i++)
 #endif
     {
-      static guint count = 0;
       test_emissions (object);
-      if (++count % 10000 == 0)
+      if (i % 10000 == 0)
         {
           g_test_message ("Yielding from main thread");
           g_thread_yield(); /* force context switch */


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]