diff options
author | Kenneth Graunke <[email protected]> | 2010-12-31 01:48:02 -0800 |
---|---|---|
committer | Kenneth Graunke <[email protected]> | 2011-01-12 23:55:33 -0800 |
commit | d7988152722cd5f3930064a139b567cbcb0e5f53 (patch) | |
tree | b17b82ce389b74e347bef5c8c43d619bdbcf5f12 /src | |
parent | daeb0c646e0d652bfa16d326028753ecf092c0c9 (diff) |
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.
Diffstat (limited to 'src')
-rw-r--r-- | src/glsl/ir_reader.cpp | 15 | ||||
-rw-r--r-- | src/glsl/s_expression.cpp | 10 | ||||
-rw-r--r-- | 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(); |