GNOME Bugzilla – Bug 622145
valac generates unnecessary duplicate code when appending to array
Last modified: 2010-06-20 08:07:02 UTC
Consider the following example void main() { int[] y = {}; y += 1; y += 2; y += 3; y += 4; } compiling this with the -C flag set, the generated C code includes the following declaration static void _vala_array_add1 (gint** array, int* length, int* size, gint value); static void _vala_array_add2 (gint** array, int* length, int* size, gint value); static void _vala_array_add3 (gint** array, int* length, int* size, gint value); static void _vala_array_add4 (gint** array, int* length, int* size, gint value); all of which have the same identical implementation. Why is it necessary to generate multiple functions with identical implementations for each statement in vala when one would be sufficient? If one were to use the append statement very often, vala would end up generating a really huge binary.
Thanks for the bug report. This particular bug has already been reported into our bug tracking system, but please feel free to report any further bugs you find. *** This bug has been marked as a duplicate of bug 621220 ***