Re: value_copy in sfiglue.c (Re: Optimizations)
- From: Stefan Westerfeld <stefan space twc de>
- To: Tim Janik <timj gtk org>
- Cc: beast gnome org
- Subject: Re: value_copy in sfiglue.c (Re: Optimizations)
- Date: Wed Feb 4 17:13:01 2004
Hi!
On Tue, Feb 03, 2004 at 08:18:36PM +0100, Tim Janik wrote:
> On Tue, 3 Feb 2004, Stefan Westerfeld wrote:
> > * Patch #1: removes redundant value copy, by appending an empty value and
> > filling it directly.
> >
> > Index: sfiglue.c
> > ===================================================================
> > RCS file: /cvs/gnome/beast/sfi/sfiglue.c,v
> > retrieving revision 1.9
> > diff -u -p -r1.9 sfiglue.c
> > --- sfiglue.c 23 Dec 2003 04:50:55 -0000 1.9
> > +++ sfiglue.c 2 Feb 2004 20:57:02 -0000
> > @@ -339,14 +339,8 @@ sfi_glue_call_valist (const gchar *proc_
> > error = g_strdup_printf ("%s: invalid category_type (%u)", G_STRLOC, arg_type);
> > else
> > {
> > - GValue value = { 0, };
> > - g_value_init (&value, collect_type);
> > - G_VALUE_COLLECT (&value, var_args, 0, &error);
> > - if (!error)
> > - {
> > - sfi_seq_append (seq, &value);
> > - g_value_unset (&value);
> > - }
> > + GValue *value = sfi_seq_append_empty (seq, collect_type);
> > + G_VALUE_COLLECT (value, var_args, 0, &error);
> > }
> > if (error)
> > {
>
> this change alters behaviour, in case of error, the original
> version doesn't append to the sequence while your version
> does (unconditionally).
But in case of error, the sequence gets freed anyway: the whole source of
the patched version is:
seq = sfi_seq_new ();
while (arg_type)
{
gchar *error = NULL;
GType collect_type = sfi_category_type (arg_type);
if (!collect_type)
error = g_strdup_printf ("%s: invalid category_type (%u)", G_STRLOC, arg_type);
else
{
GValue *value = sfi_seq_append_empty (seq, collect_type);
G_VALUE_COLLECT (value, var_args, 0, &error);
}
if (error)
{
sfi_warn ("%s: %s", G_STRLOC, error);
g_free (error);
sfi_seq_unref (seq);
return NULL;
}
arg_type = va_arg (var_args, guint);
}
So if an error occurs, the new version appends unconditionally, but it also
frees the resulting sequence if an error occured.
Cu... Stefan
--
-* Stefan Westerfeld, stefan@space.twc.de (PGP!), Hamburg/Germany
KDE Developer, project infos at http://space.twc.de/~stefan/kde *-
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]