[Mesa-dev] [PATCH v3 11/15] anv: anv_entrypoints_gen.py: use reduce function.

Dylan Baker dylan at pnwbakers.com
Fri Feb 24 18:21:39 UTC 2017


Reduce is it's own reward.

Signed-off-by: Dylan Baker <dylanx.c.baker at intel.com>
---
 src/intel/vulkan/anv_entrypoints_gen.py | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/src/intel/vulkan/anv_entrypoints_gen.py b/src/intel/vulkan/anv_entrypoints_gen.py
index 8460bb5..7a5d0a7 100644
--- a/src/intel/vulkan/anv_entrypoints_gen.py
+++ b/src/intel/vulkan/anv_entrypoints_gen.py
@@ -23,6 +23,7 @@
 #
 
 import argparse
+import functools
 import os
 import textwrap
 import xml.etree.ElementTree as et
@@ -256,11 +257,8 @@ PRIME_STEP = 19
 
 def cal_hash(name):
     """Calculate the same hash value that Mesa will calculate in C."""
-    h = 0
-    for c in name:
-        h = (h * PRIME_FACTOR + ord(c)) & U32_MASK
-
-    return h
+    return functools.reduce(
+        lambda h, c: (h * PRIME_FACTOR + ord(c)) & U32_MASK, name, 0)
 
 
 def get_entrypoints(doc, entrypoints_to_defines):
-- 
git-series 0.9.1


More information about the mesa-dev mailing list