exec_list: Make various places use the new length() method.
authorConnor Abbott <cwabbott0@gmail.com>
Tue, 8 Jul 2014 19:21:00 +0000 (12:21 -0700)
committerMatt Turner <mattst88@gmail.com>
Tue, 15 Jul 2014 18:16:16 +0000 (11:16 -0700)
Instead of hand-rolling it.

v2 [mattst88]: Rename get_size to length. Expand comment in ir_reader.

Reviewed-by: Ian Romanick <ian.d.romanick@intel.com> [v1]
Reviewed-by: Matt Turner <mattst88@gmail.com>
Signed-off-by: Connor Abbott <connor.abbott@intel.com>
src/glsl/ast_to_hir.cpp
src/glsl/ir_reader.cpp
src/glsl/opt_function_inlining.cpp
src/mesa/drivers/dri/i965/brw_fs.cpp
src/mesa/drivers/dri/i965/brw_fs_copy_propagation.cpp
src/mesa/program/ir_to_mesa.cpp

index 885bee547f6037036702050be53ba14c45b3b5d6..8ef8bf92ce6d1792af9c6c8fc7322834efd1e59c 100644 (file)
@@ -5007,9 +5007,7 @@ ast_process_structure_or_interface_block(exec_list *instructions,
     * 'declarations' list in each of the elements.
     */
    foreach_list_typed (ast_declarator_list, decl_list, link, declarations) {
-      foreach_list_typed (ast_declaration, decl, link, &decl_list->declarations) {
-         decl_count++;
-      }
+      decl_count += decl_list->declarations.length();
    }
 
    /* Allocate storage for the fields and process the field
index 4017bdd736ce2ac35c7ae4eb11df5af5c822d174..e3566e1d6966e6729f6c66e2bf5cb8f2bdbbe026 100644 (file)
@@ -723,10 +723,9 @@ ir_reader::read_expression(s_expression *expr)
       ir_read_error(expr, "invalid operator: %s", s_op->value());
       return NULL;
    }
-    
-   int num_operands = -3; /* skip "expression" <type> <operation> */
-   foreach_in_list(s_expression, e, &((s_list *) expr)->subexpressions)
-      ++num_operands;
+
+   /* Skip "expression" <type> <operation> by subtracting 3. */
+   int num_operands = (int) ((s_list *) expr)->subexpressions.length() - 3;
 
    int expected_operands = ir_expression::get_num_operands(op);
    if (num_operands != expected_operands) {
index b84bb8e11bb7f1e8e3c24f7b1d8575abe2ae799b..64b4907bab95a3fa81170b93f5bca4c03dd9c94c 100644 (file)
@@ -100,16 +100,13 @@ ir_call::generate_inline(ir_instruction *next_ir)
 {
    void *ctx = ralloc_parent(this);
    ir_variable **parameters;
-   int num_parameters;
+   unsigned num_parameters;
    int i;
    struct hash_table *ht;
 
    ht = hash_table_ctor(0, hash_table_pointer_hash, hash_table_pointer_compare);
 
-   num_parameters = 0;
-   foreach_in_list(ir_rvalue, param, &this->callee->parameters)
-      num_parameters++;
-
+   num_parameters = this->callee->parameters.length();
    parameters = new ir_variable *[num_parameters];
 
    /* Generate the declarations for the parameters to our inlined code,
index 951d69f51306496f6eac7f4f97b731d9413bca45..56a0183a7395d7aad8a61b2dbaf1baef7f9c7367 100644 (file)
@@ -2965,10 +2965,7 @@ fs_visitor::calculate_register_pressure()
    invalidate_live_intervals();
    calculate_live_intervals();
 
-   int num_instructions = 0;
-   foreach_in_list(fs_inst, inst, &instructions) {
-      ++num_instructions;
-   }
+   unsigned num_instructions = instructions.length();
 
    regs_live_at_ip = rzalloc_array(mem_ctx, int, num_instructions);
 
index 28e59c6c80789484ede88bd389506590893ac9cd..10e19d82ca6357d030d552dadfe4c67ee20c45f1 100644 (file)
@@ -106,9 +106,7 @@ fs_copy_prop_dataflow::fs_copy_prop_dataflow(void *mem_ctx, cfg_t *cfg,
    num_acp = 0;
    for (int b = 0; b < cfg->num_blocks; b++) {
       for (int i = 0; i < ACP_HASH_SIZE; i++) {
-         foreach_in_list(acp_entry, entry, &out_acp[b][i]) {
-            num_acp++;
-         }
+         num_acp += out_acp[b][i].length();
       }
    }
 
index 8aefcf7e2b35842ea7648f795e020100b49d8f5e..2a82e9d9ddc81a925a74d40fa0a2a315b700bef3 100644 (file)
@@ -2817,10 +2817,7 @@ get_mesa_program(struct gl_context *ctx,
 
    prog->NumTemporaries = v.next_temp;
 
-   int num_instructions = 0;
-   foreach_in_list(ir_instruction, node, &v.instructions) {
-      num_instructions++;
-   }
+   unsigned num_instructions = v.instructions.length();
 
    mesa_instructions =
       (struct prog_instruction *)calloc(num_instructions,