Re: [Mesa-dev] [PATCH 2/3] exec_list: add a function to count the size of a list

2014-07-09 Thread Ian Romanick
On 07/08/2014 12:20 PM, Connor Abbott wrote:
 Signed-off-by: Connor Abbott connor.abb...@intel.com
 ---
  src/glsl/list.h | 20 
  1 file changed, 20 insertions(+)
 
 diff --git a/src/glsl/list.h b/src/glsl/list.h
 index ca6ee9d..68ab3fd 100644
 --- a/src/glsl/list.h
 +++ b/src/glsl/list.h
 @@ -324,6 +324,8 @@ struct exec_list {
  
 const exec_node *get_tail() const;
 exec_node *get_tail();
 +   
 +   unsigned get_size();
  
 void push_head(exec_node *n);
 void push_tail(exec_node *n);
 @@ -405,6 +407,19 @@ exec_list_get_tail(struct exec_list *list)
 return !exec_list_is_empty(list) ? list-tail_pred : NULL;
  }
  
 +static inline unsigned
 +exec_list_get_size(struct exec_list *list)
 +{
 +   unsigned size = 0;
 +   
 +   for (struct exec_node *node = list-head; node-next != NULL;
 + node = node-next) {

Maybe use foreach_in_list?  Since Matt was so nice to create it... :)

 +  size++;
 +   }
 +   
 +   return size;
 +}
 +
  static inline void
  exec_list_push_head(struct exec_list *list, struct exec_node *n)
  {
 @@ -537,6 +552,11 @@ inline exec_node *exec_list::get_tail()
 return exec_list_get_tail(this);
  }
  
 +inline unsigned exec_list::get_size()
 +{
 +   return exec_list_get_size(this);
 +}
 +
  inline void exec_list::push_head(exec_node *n)
  {
 exec_list_push_head(this, n);
 

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 2/3] exec_list: add a function to count the size of a list

2014-07-09 Thread Matt Turner
On Tue, Jul 8, 2014 at 12:20 PM, Connor Abbott cwabbo...@gmail.com wrote:
 Signed-off-by: Connor Abbott connor.abb...@intel.com
 ---
  src/glsl/list.h | 20 
  1 file changed, 20 insertions(+)

 diff --git a/src/glsl/list.h b/src/glsl/list.h
 index ca6ee9d..68ab3fd 100644
 --- a/src/glsl/list.h
 +++ b/src/glsl/list.h
 @@ -324,6 +324,8 @@ struct exec_list {

 const exec_node *get_tail() const;
 exec_node *get_tail();
 +
 +   unsigned get_size();

 void push_head(exec_node *n);
 void push_tail(exec_node *n);
 @@ -405,6 +407,19 @@ exec_list_get_tail(struct exec_list *list)
 return !exec_list_is_empty(list) ? list-tail_pred : NULL;
  }

 +static inline unsigned
 +exec_list_get_size(struct exec_list *list)

I'd probably name this _length(), and move the function below the
macros so you can use foreach_in_list.

Other than that, the series is

Reviewed-by: Matt Turner matts...@gmail.com
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 2/3] exec_list: add a function to count the size of a list

2014-07-09 Thread Connor Abbott
On Wednesday, July 09, 2014 03:56:41 PM Ian Romanick wrote:
 On 07/08/2014 12:20 PM, Connor Abbott wrote:
  Signed-off-by: Connor Abbott connor.abb...@intel.com
  ---
  
   src/glsl/list.h | 20 
   1 file changed, 20 insertions(+)
  
  diff --git a/src/glsl/list.h b/src/glsl/list.h
  index ca6ee9d..68ab3fd 100644
  --- a/src/glsl/list.h
  +++ b/src/glsl/list.h
  @@ -324,6 +324,8 @@ struct exec_list {
  
  const exec_node *get_tail() const;
  exec_node *get_tail();
  
  +
  +   unsigned get_size();
  
  void push_head(exec_node *n);
  void push_tail(exec_node *n);
  
  @@ -405,6 +407,19 @@ exec_list_get_tail(struct exec_list *list)
  
  return !exec_list_is_empty(list) ? list-tail_pred : NULL;
   
   }
  
  +static inline unsigned
  +exec_list_get_size(struct exec_list *list)
  +{
  +   unsigned size = 0;
  +
  +   for (struct exec_node *node = list-head; node-next != NULL;
  +   node = node-next) {
 
 Maybe use foreach_in_list?  Since Matt was so nice to create it... :)

I would, except first of all, it's doing some typecasting we don't need to do, 
and second of all, it's defined after this point (at the end of the file) and I 
didn't bother to move it up. If you think it's worth it though, I'm fine with 
changing it...

 
  +  size++;
  +   }
  +
  +   return size;
  +}
  +
  
   static inline void
   exec_list_push_head(struct exec_list *list, struct exec_node *n)
   {
  
  @@ -537,6 +552,11 @@ inline exec_node *exec_list::get_tail()
  
  return exec_list_get_tail(this);
   
   }
  
  +inline unsigned exec_list::get_size()
  +{
  +   return exec_list_get_size(this);
  +}
  +
  
   inline void exec_list::push_head(exec_node *n)
   {
   
  exec_list_push_head(this, n);

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 2/3] exec_list: add a function to count the size of a list

2014-07-09 Thread Matt Turner
On Wed, Jul 9, 2014 at 4:00 PM, Connor Abbott connor.abb...@intel.com wrote:
 On Wednesday, July 09, 2014 03:56:41 PM Ian Romanick wrote:
 On 07/08/2014 12:20 PM, Connor Abbott wrote:
  Signed-off-by: Connor Abbott connor.abb...@intel.com
  ---
 
   src/glsl/list.h | 20 
   1 file changed, 20 insertions(+)
 
  diff --git a/src/glsl/list.h b/src/glsl/list.h
  index ca6ee9d..68ab3fd 100644
  --- a/src/glsl/list.h
  +++ b/src/glsl/list.h
  @@ -324,6 +324,8 @@ struct exec_list {
 
  const exec_node *get_tail() const;
  exec_node *get_tail();
 
  +
  +   unsigned get_size();
 
  void push_head(exec_node *n);
  void push_tail(exec_node *n);
 
  @@ -405,6 +407,19 @@ exec_list_get_tail(struct exec_list *list)
 
  return !exec_list_is_empty(list) ? list-tail_pred : NULL;
 
   }
 
  +static inline unsigned
  +exec_list_get_size(struct exec_list *list)
  +{
  +   unsigned size = 0;
  +
  +   for (struct exec_node *node = list-head; node-next != NULL;
  +   node = node-next) {

 Maybe use foreach_in_list?  Since Matt was so nice to create it... :)

 I would, except first of all, it's doing some typecasting we don't need to do,
 and second of all, it's defined after this point (at the end of the file) and 
 I
 didn't bother to move it up. If you think it's worth it though, I'm fine with
 changing it...

Right.. I guess not much point if you don't need the cast.
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH 2/3] exec_list: add a function to count the size of a list

2014-07-08 Thread Connor Abbott
Signed-off-by: Connor Abbott connor.abb...@intel.com
---
 src/glsl/list.h | 20 
 1 file changed, 20 insertions(+)

diff --git a/src/glsl/list.h b/src/glsl/list.h
index ca6ee9d..68ab3fd 100644
--- a/src/glsl/list.h
+++ b/src/glsl/list.h
@@ -324,6 +324,8 @@ struct exec_list {
 
const exec_node *get_tail() const;
exec_node *get_tail();
+   
+   unsigned get_size();
 
void push_head(exec_node *n);
void push_tail(exec_node *n);
@@ -405,6 +407,19 @@ exec_list_get_tail(struct exec_list *list)
return !exec_list_is_empty(list) ? list-tail_pred : NULL;
 }
 
+static inline unsigned
+exec_list_get_size(struct exec_list *list)
+{
+   unsigned size = 0;
+   
+   for (struct exec_node *node = list-head; node-next != NULL;
+   node = node-next) {
+  size++;
+   }
+   
+   return size;
+}
+
 static inline void
 exec_list_push_head(struct exec_list *list, struct exec_node *n)
 {
@@ -537,6 +552,11 @@ inline exec_node *exec_list::get_tail()
return exec_list_get_tail(this);
 }
 
+inline unsigned exec_list::get_size()
+{
+   return exec_list_get_size(this);
+}
+
 inline void exec_list::push_head(exec_node *n)
 {
exec_list_push_head(this, n);
-- 
1.9.3

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev