[Mesa-dev] [PATCH 39/41] glapi: glX_server_table.py: use math.log instead of hand coded log2 function

Ian Romanick idr at freedesktop.org
Tue Apr 19 23:46:05 UTC 2016


This patch is

Reviewed-by: Ian Romanick <ian.d.romanick at intel.com>

On 03/31/2016 05:04 PM, Dylan Baker wrote:
> 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
>  
> 



More information about the mesa-dev mailing list