[perl-Glib] Avoid a needless initialization inside a loop



commit eac485950faa3ddb6211ee1e37e8d6c80935d925
Author: Kevin Ryde <user42 zip com au>
Date:   Sat Jun 6 19:40:48 2009 +0200

    Avoid a needless initialization inside a loop
    
    g_value_unset() clears the GValue to zero, so there's no need to initialize a
    new GValue to zero for every iteration; we can just reuse a single one.
---
 GClosure.xs |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/GClosure.xs b/GClosure.xs
index f322bf1..da063fb 100644
--- a/GClosure.xs
+++ b/GClosure.xs
@@ -365,6 +365,7 @@ gperl_callback_invoke (GPerlCallback * callback,
 	/* put args on the stack */
 	if (callback->n_params > 0) {
 		int i;
+		GValue v = {0, };
 
                 /* Crib note: must g_value_unset() even when asking for
                  * G_VALUE_NOCOPY_CONTENTS.  A GObject is always
@@ -378,7 +379,6 @@ gperl_callback_invoke (GPerlCallback * callback,
                  */
 		for (i = 0 ; i < callback->n_params ; i++) {
 			gchar * error = NULL;
-			GValue v = {0, };
 			SV * sv;
 			g_value_init (&v, callback->param_types[i]);
 			G_VALUE_COLLECT (&v, var_args, G_VALUE_NOCOPY_CONTENTS,



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