diff options
author | Connor Abbott <[email protected]> | 2014-07-08 12:21:00 -0700 |
---|---|---|
committer | Matt Turner <[email protected]> | 2014-07-15 11:16:16 -0700 |
commit | 58270c2fac493497ed7923830f49051a53e86a07 (patch) | |
tree | ca7bbef19c575c452b524b8432beedcda30e8fee | |
parent | 7b0f69225afb362ec2681d9b36eae2d035b10c00 (diff) |
exec_list: Make various places use the new length() method.
Instead of hand-rolling it.
v2 [mattst88]: Rename get_size to length. Expand comment in ir_reader.
Reviewed-by: Ian Romanick <[email protected]> [v1]
Reviewed-by: Matt Turner <[email protected]>
Signed-off-by: Connor Abbott <[email protected]>
-rw-r--r-- | src/glsl/ast_to_hir.cpp | 4 | ||||
-rw-r--r-- | src/glsl/ir_reader.cpp | 7 | ||||
-rw-r--r-- | src/glsl/opt_function_inlining.cpp | 7 | ||||
-rw-r--r-- | src/mesa/drivers/dri/i965/brw_fs.cpp | 5 | ||||
-rw-r--r-- | src/mesa/drivers/dri/i965/brw_fs_copy_propagation.cpp | 4 | ||||
-rw-r--r-- | src/mesa/program/ir_to_mesa.cpp | 5 |
6 files changed, 9 insertions, 23 deletions
diff --git a/src/glsl/ast_to_hir.cpp b/src/glsl/ast_to_hir.cpp index 885bee547f6..8ef8bf92ce6 100644 --- a/src/glsl/ast_to_hir.cpp +++ b/src/glsl/ast_to_hir.cpp @@ -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 diff --git a/src/glsl/ir_reader.cpp b/src/glsl/ir_reader.cpp index 4017bdd736c..e3566e1d696 100644 --- a/src/glsl/ir_reader.cpp +++ b/src/glsl/ir_reader.cpp @@ -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) { diff --git a/src/glsl/opt_function_inlining.cpp b/src/glsl/opt_function_inlining.cpp index b84bb8e11bb..64b4907bab9 100644 --- a/src/glsl/opt_function_inlining.cpp +++ b/src/glsl/opt_function_inlining.cpp @@ -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, diff --git a/src/mesa/drivers/dri/i965/brw_fs.cpp b/src/mesa/drivers/dri/i965/brw_fs.cpp index 951d69f5130..56a0183a739 100644 --- a/src/mesa/drivers/dri/i965/brw_fs.cpp +++ b/src/mesa/drivers/dri/i965/brw_fs.cpp @@ -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); diff --git a/src/mesa/drivers/dri/i965/brw_fs_copy_propagation.cpp b/src/mesa/drivers/dri/i965/brw_fs_copy_propagation.cpp index 28e59c6c807..10e19d82ca6 100644 --- a/src/mesa/drivers/dri/i965/brw_fs_copy_propagation.cpp +++ b/src/mesa/drivers/dri/i965/brw_fs_copy_propagation.cpp @@ -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(); } } diff --git a/src/mesa/program/ir_to_mesa.cpp b/src/mesa/program/ir_to_mesa.cpp index 8aefcf7e2b3..2a82e9d9ddc 100644 --- a/src/mesa/program/ir_to_mesa.cpp +++ b/src/mesa/program/ir_to_mesa.cpp @@ -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, |