[Mesa-dev] [PATCH 15/41] glapi: remove useless 0 start parameter for (x)range

Ian Romanick idr at freedesktop.org
Tue Apr 19 22:00:02 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:
> Python's range and xrange functions start at 0 by default anyway, so
> don't bother setting it explicitly to 0.
> 
> Signed-off-by: Dylan Baker <dylanx.c.baker at intel.com>
> ---
>  src/mapi/glapi/gen/glX_proto_size.py   |  2 +-
>  src/mapi/glapi/gen/glX_server_table.py |  4 ++--
>  src/mapi/glapi/gen/gl_XML.py           | 10 +++++-----
>  src/mapi/glapi/gen/gl_gentable.py      |  4 ++--
>  4 files changed, 10 insertions(+), 10 deletions(-)
> 
> diff --git a/src/mapi/glapi/gen/glX_proto_size.py b/src/mapi/glapi/gen/glX_proto_size.py
> index 0c0b106..46ac61e 100644
> --- a/src/mapi/glapi/gen/glX_proto_size.py
> +++ b/src/mapi/glapi/gen/glX_proto_size.py
> @@ -151,7 +151,7 @@ class glx_enum_function(object):
>              masked_enums = {}
>              masked_count = {}
>  
> -            for i in xrange(0, mask + 1):
> +            for i in xrange(mask + 1):
>                  masked_enums[i] = "0"
>                  masked_count[i] = 0
>  
> diff --git a/src/mapi/glapi/gen/glX_server_table.py b/src/mapi/glapi/gen/glX_server_table.py
> index 6443a99..e67ff70 100644
> --- a/src/mapi/glapi/gen/glX_server_table.py
> +++ b/src/mapi/glapi/gen/glX_server_table.py
> @@ -35,7 +35,7 @@ import license
>  
>  
>  def log2(value):
> -    for i in xrange(0, 30):
> +    for i in xrange(30):
>          p = 1 << i
>          if p >= value:
>              return i
> @@ -95,7 +95,7 @@ class function_table:
>          next_opcode = min_opcode + (1 << remaining_bits)
>          empty_children = 0
>  
> -        for M in xrange(0, remaining_bits):
> +        for M in xrange(remaining_bits):
>              op_count = 1 << (remaining_bits - M)
>              child_count = 1 << M
>  
> diff --git a/src/mapi/glapi/gen/gl_XML.py b/src/mapi/glapi/gen/gl_XML.py
> index 695ef7f..f1606a6 100644
> --- a/src/mapi/glapi/gen/gl_XML.py
> +++ b/src/mapi/glapi/gen/gl_XML.py
> @@ -685,7 +685,7 @@ class gl_function(gl_item):
>              if len(parameters) != len(self.parameters):
>                  raise RuntimeError("Parameter count mismatch in %s.  Was %d, now %d." % (name, len(self.parameters), len(parameters)))
>  
> -            for j in xrange(0, len(parameters)):
> +            for j in xrange(len(parameters)):
>                  p1 = parameters[j]
>                  p2 = self.parameters[j]
>                  if not p1.compatible(p2):
> @@ -924,7 +924,7 @@ class gl_api(object):
>  
>  
>          functions = []
> -        for func_cat_type in range(0,4):
> +        for func_cat_type in range(4):
>              keys = lists[func_cat_type].keys()
>              keys.sort()
>  
> @@ -943,13 +943,13 @@ class gl_api(object):
>              if func.offset > max_offset:
>                  max_offset = func.offset
>  
> -        temp = [None for i in range(0, max_offset + 1)]
> +        temp = [None for i in range(max_offset + 1)]
>          for func in self.functions_by_name.itervalues():
>              if func.offset != -1:
>                  temp[func.offset] = func
>  
>          list = []
> -        for i in range(0, max_offset + 1):
> +        for i in range(max_offset + 1):
>              if temp[i]:
>                  list.append(temp[i])
>  
> @@ -976,7 +976,7 @@ class gl_api(object):
>          name and number (which may be None) of the category.
>          """
>          list = []
> -        for cat_type in xrange(0,4):
> +        for cat_type in xrange(4):
>              keys = self.categories[cat_type].keys()
>              keys.sort()
>  
> diff --git a/src/mapi/glapi/gen/gl_gentable.py b/src/mapi/glapi/gen/gl_gentable.py
> index 40da816..a3f3e54 100644
> --- a/src/mapi/glapi/gen/gl_gentable.py
> +++ b/src/mapi/glapi/gen/gl_gentable.py
> @@ -197,13 +197,13 @@ class PrintCode(gl_XML.gl_print_base):
>  
>          # Check that the table has no gaps.  We expect a function at every offset,
>          # and the code which generates the table relies on this.
> -        for i in xrange(0, func_count):
> +        for i in xrange(func_count):
>              if funcnames[i] is None:
>                  raise Exception("Function table has no function at offset %d" % (i))
>  
>          print "#define GLAPI_TABLE_COUNT %d" % func_count
>          print "static const char * const _glapi_table_func_names[GLAPI_TABLE_COUNT] = {"
> -        for i in xrange(0, func_count):
> +        for i in xrange(func_count):
>              print "    /* %5d */ \"%s\"," % (i, funcnames[i])
>          print "};"
>  
> 



More information about the mesa-dev mailing list