[Piglit] [PATCH 3/4] gen_const_builtin_equal_tests.py: use enumerate instead of a flag
Dylan Baker
baker.dylan.c at gmail.com
Mon May 19 15:01:11 PDT 2014
On Monday, May 19, 2014 17:56:41 Ilia Mirkin wrote:
> On Mon, May 19, 2014 at 5:43 PM, Dylan Baker <baker.dylan.c at gmail.com> wrote:
> > This combines the two loops into a single loop using enumerate. This
> > should be a little faster since we loop over the data only once, and
> > since it uses enumerate instead of math.
> >
> > Signed-off-by: Dylan Baker <baker.dylan.c at gmail.com>
> > ---
> > generated_tests/gen_const_builtin_equal_tests.py | 17 +++++++----------
> > 1 file changed, 7 insertions(+), 10 deletions(-)
> >
> > diff --git a/generated_tests/gen_const_builtin_equal_tests.py b/generated_tests/gen_const_builtin_equal_tests.py
> > index 4519184..79b5a1d 100644
> > --- a/generated_tests/gen_const_builtin_equal_tests.py
> > +++ b/generated_tests/gen_const_builtin_equal_tests.py
> > @@ -104,22 +104,19 @@ def main():
> > except OSError:
> > pass
> >
> > - test_id = 2
> > - for x in test_vectors:
> > - name = "spec/glsl-1.20/execution/built-in-functions/glsl-const-builtin-equal-%02d.shader_test" % test_id
> > - test_id = test_id + 1
> > -
> > + for test_id, x in enumerate(test_vectors, 2):
>
> While I'm not totally against this, I'd like you to consider just
> adding the 2 below to test_id. I believe that I'm fairly knowledgeable
> about python builtins, and I still had to look that up -- I had never
> come across it before.
Is it enumerate you haven't seen before, or setting the start value for
enumerate?
>
> > + # make equal tests
> > + name = ("spec/glsl-1.20/execution/built-in-functions/"
> > + "glsl-const-builtin-equal-{0:02d}.shader_test".format(test_id))
> > print(name)
> >
> > with open(name, 'w+') as f:
> > f.write(TEMPLATE.render_unicode(
> > func='equal', input=x[0:2], expected=x[2]))
> >
> > -
> > - test_id = 2
> > - for x in test_vectors:
> > - name = "spec/glsl-1.20/execution/built-in-functions/glsl-const-builtin-notEqual-%02d.shader_test" % test_id
> > - test_id = test_id + 1
> > + # make notEqual tests
> > + name = ("spec/glsl-1.20/execution/built-in-functions/"
> > + "glsl-const-builtin-notEqual-{0:02d}.shader_test".format(test_id))
> >
> > # When generating the notEqual tests, each of the values in the
> > # expected result vector need to be inverted
> > --
> > 2.0.0.rc2
> >
> > _______________________________________________
> > Piglit mailing list
> > Piglit at lists.freedesktop.org
> > http://lists.freedesktop.org/mailman/listinfo/piglit
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/piglit/attachments/20140519/fd8e4593/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 490 bytes
Desc: This is a digitally signed message part.
URL: <http://lists.freedesktop.org/archives/piglit/attachments/20140519/fd8e4593/attachment-0001.sig>
More information about the Piglit
mailing list