Wow. It's surprising how many places that shows up! Reviewed-by: Ian Romanick <ian.d.roman...@intel.com>
On 07/08/2014 12:21 PM, Connor Abbott wrote: > Instead of hand-rolling it. > > Signed-off-by: Connor Abbott <connor.abb...@intel.com> > --- > src/glsl/ast_to_hir.cpp | 4 +--- > src/glsl/ir_reader.cpp | 7 +++---- > src/glsl/opt_function_inlining.cpp | 7 ++----- > src/mesa/drivers/dri/i965/brw_fs.cpp | 5 +---- > src/mesa/drivers/dri/i965/brw_fs_copy_propagation.cpp | 4 +--- > 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 885bee5..a2ab26b 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.get_size(); > } > > /* Allocate storage for the fields and process the field > diff --git a/src/glsl/ir_reader.cpp b/src/glsl/ir_reader.cpp > index 4017bdd..4f141de 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> */ > + int num_operands = (int) ((s_list *) expr)->subexpressions.get_size() - 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 b84bb8e..9626639 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.get_size(); > 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 a3ad375..6ab82b9 100644 > --- a/src/mesa/drivers/dri/i965/brw_fs.cpp > +++ b/src/mesa/drivers/dri/i965/brw_fs.cpp > @@ -2957,10 +2957,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.get_size(); > > 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 28e59c6..ce8dc36 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].get_size(); > } > } > > diff --git a/src/mesa/program/ir_to_mesa.cpp b/src/mesa/program/ir_to_mesa.cpp > index 1109051..cc9c8ae 100644 > --- a/src/mesa/program/ir_to_mesa.cpp > +++ b/src/mesa/program/ir_to_mesa.cpp > @@ -2814,10 +2814,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.get_size(); > > mesa_instructions = > (struct prog_instruction *)calloc(num_instructions, > _______________________________________________ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev