Mesa (master): python: Use the right function for the job

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Thu Aug 9 23:50:36 UTC 2018


Module: Mesa
Branch: master
Commit: d9ca4a172e8e8a42217588ca1b83a7ceb5bf3f76
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=d9ca4a172e8e8a42217588ca1b83a7ceb5bf3f76

Author: Mathieu Bridon <bochecha at daitauha.fr>
Date:   Thu Aug  9 10:27:19 2018 +0200

python: Use the right function for the job

The code was just reimplementing itertools.combinations_with_replacement
in a less efficient way.

This does change the order of the results slightly, but it should be ok.

Signed-off-by: Mathieu Bridon <bochecha at daitauha.fr>
Reviewed-by: Dylan Baker <dylan at pnwbakers.com>

---

 src/compiler/nir/nir_opt_algebraic.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/compiler/nir/nir_opt_algebraic.py b/src/compiler/nir/nir_opt_algebraic.py
index ac53d77383..e770a61d9f 100644
--- a/src/compiler/nir/nir_opt_algebraic.py
+++ b/src/compiler/nir/nir_opt_algebraic.py
@@ -723,7 +723,7 @@ optimizations = [
 
 invert = OrderedDict([('feq', 'fne'), ('fne', 'feq'), ('fge', 'flt'), ('flt', 'fge')])
 
-for left, right in list(itertools.combinations(invert.keys(), 2)) + zip(invert.keys(), invert.keys()):
+for left, right in itertools.combinations_with_replacement(invert.keys(), 2):
    optimizations.append((('inot', ('ior(is_used_once)', (left, a, b), (right, c, d))),
                          ('iand', (invert[left], a, b), (invert[right], c, d))))
    optimizations.append((('inot', ('iand(is_used_once)', (left, a, b), (right, c, d))),




More information about the mesa-commit mailing list