]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
codegen: Use array_length of collection variable instead of expression
authorRico Tzschichholz <ricotz@ubuntu.com>
Thu, 13 Jun 2019 13:58:58 +0000 (15:58 +0200)
committerRico Tzschichholz <ricotz@ubuntu.com>
Tue, 6 Aug 2019 11:56:27 +0000 (13:56 +0200)
codegen/valaccodecontrolflowmodule.vala

index a549f062127c5d901d5adeb7d965be8f1e716062..b85aca9002bba46fa32f747997527780ea8c7039 100644 (file)
@@ -237,10 +237,10 @@ public abstract class Vala.CCodeControlFlowModule : CCodeMethodModule {
                if (stmt.collection.value_type is ArrayType) {
                        array_type = (ArrayType) stmt.collection.value_type;
 
-                       var array_len = get_array_length_cexpression (stmt.collection);
+                       var array_len = get_variable_cexpression (get_array_length_cname (get_local_cname (collection_backup), 1));
 
                        // store array length for use by _vala_array_free
-                       ccode.add_assignment (get_variable_cexpression (get_array_length_cname (get_local_cname (collection_backup), 1)), array_len);
+                       ccode.add_assignment (array_len, get_array_length_cexpression (stmt.collection));
 
                        var iterator_variable = new LocalVariable (int_type.copy (), stmt.variable_name + "_it");
                        visit_local_variable (iterator_variable);