[Mesa-dev] [PATCH 39/41] glapi: glX_server_table.py: use math.log instead of hand coded log2 function
Dylan Baker
baker.dylan.c at gmail.com
Fri Apr 1 00:04:56 UTC 2016
This just saves a bit of typing.
Signed-off-by: Dylan Baker <dylanx.c.baker at intel.com>
---
src/mapi/glapi/gen/glX_server_table.py | 12 ++----------
1 file changed, 2 insertions(+), 10 deletions(-)
diff --git a/src/mapi/glapi/gen/glX_server_table.py b/src/mapi/glapi/gen/glX_server_table.py
index 4549fbd..a4bc04f 100644
--- a/src/mapi/glapi/gen/glX_server_table.py
+++ b/src/mapi/glapi/gen/glX_server_table.py
@@ -27,6 +27,7 @@
# Ian Romanick <idr at us.ibm.com>
import argparse
+import math
import glX_XML
import glX_proto_common
@@ -34,15 +35,6 @@ import gl_XML
import license
-def log2(value):
- for i in xrange(30):
- p = 1 << i
- if p >= value:
- return i
-
- return -1
-
-
def round_down_to_power_of_two(n):
"""Returns the nearest power-of-two less than or equal to n."""
@@ -77,7 +69,7 @@ class function_table:
self.max_opcode = opcode
if opcode > self.next_opcode_threshold:
- bits = log2(opcode)
+ bits = int(math.log(opcode, 2))
if (1 << bits) <= opcode:
bits += 1
--
2.8.0
More information about the mesa-dev
mailing list