From d7988152722cd5f3930064a139b567cbcb0e5f53 Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Fri, 31 Dec 2010 01:48:02 -0800 Subject: [PATCH] ir_reader: Remove s_list::length() method. Most code now relies on the pattern matcher rather than this function, and for the only remaining case, not using this saves an iteration. --- src/glsl/ir_reader.cpp | 15 ++++++++------- src/glsl/s_expression.cpp | 10 ---------- src/glsl/s_expression.h | 1 - 3 files changed, 8 insertions(+), 18 deletions(-) diff --git a/src/glsl/ir_reader.cpp b/src/glsl/ir_reader.cpp index 00146d8c15e..98906c4ad73 100644 --- a/src/glsl/ir_reader.cpp +++ b/src/glsl/ir_reader.cpp @@ -754,13 +754,7 @@ read_constant(_mesa_glsl_parse_state *st, s_list *list) } if (type->is_array()) { - const unsigned elements_supplied = values->length(); - if (elements_supplied != type->length) { - ir_read_error(st, values, "expected exactly %u array elements, " - "given %u", type->length, elements_supplied); - return NULL; - } - + unsigned elements_supplied = 0; exec_list elements; foreach_iter(exec_list_iterator, it, values->subexpressions) { s_expression *expr = (s_expression *) it.get(); @@ -774,6 +768,13 @@ read_constant(_mesa_glsl_parse_state *st, s_list *list) if (ir_elt == NULL) return NULL; elements.push_tail(ir_elt); + elements_supplied++; + } + + if (elements_supplied != type->length) { + ir_read_error(st, values, "expected exactly %u array elements, " + "given %u", type->length, elements_supplied); + return NULL; } return new(ctx) ir_constant(type, &elements); } diff --git a/src/glsl/s_expression.cpp b/src/glsl/s_expression.cpp index a00bfa73ed1..852a049d43f 100644 --- a/src/glsl/s_expression.cpp +++ b/src/glsl/s_expression.cpp @@ -38,16 +38,6 @@ s_list::s_list() { } -unsigned -s_list::length() const -{ - unsigned i = 0; - foreach_iter(exec_list_iterator, it, this->subexpressions) { - i++; - } - return i; -} - static s_expression * read_atom(void *ctx, const char *& src) { diff --git a/src/glsl/s_expression.h b/src/glsl/s_expression.h index c444ba4338d..795f3fccea7 100644 --- a/src/glsl/s_expression.h +++ b/src/glsl/s_expression.h @@ -139,7 +139,6 @@ public: s_list(); virtual bool is_list() const { return true; } - unsigned length() const; void print(); -- 2.30.2