[Mesa-dev] [PATCH 12/23] glsl: Change link_functions to use a set

Thomas Helland thomashelland90 at gmail.com
Tue Aug 16 20:10:25 UTC 2016


The "locals" hash table is used as a set, so use a set to
avoid confusion and also spare some minor memory.

Signed-off-by: Thomas Helland <thomashelland90 at gmail.com>
---
 src/compiler/glsl/link_functions.cpp | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/src/compiler/glsl/link_functions.cpp b/src/compiler/glsl/link_functions.cpp
index 69bdef1..b4aae5e 100644
--- a/src/compiler/glsl/link_functions.cpp
+++ b/src/compiler/glsl/link_functions.cpp
@@ -26,6 +26,7 @@
 #include "glsl_parser_extras.h"
 #include "ir.h"
 #include "program.h"
+#include "util/set.h"
 #include "util/hash_table.h"
 #include "linker.h"
 
@@ -46,18 +47,18 @@ public:
       this->success = true;
       this->linked = linked;
 
-      this->locals = _mesa_hash_table_create(NULL, _mesa_hash_pointer,
-                                             _mesa_key_pointer_equal);
+      this->locals = _mesa_set_create(NULL, _mesa_hash_pointer,
+                                      _mesa_key_pointer_equal);
    }
 
    ~call_link_visitor()
    {
-      _mesa_hash_table_destroy(this->locals, NULL);
+      _mesa_set_destroy(this->locals, NULL);
    }
 
    virtual ir_visitor_status visit(ir_variable *ir)
    {
-      _mesa_hash_table_insert(locals, ir, ir);
+      _mesa_set_add(locals, ir);
       return visit_continue;
    }
 
@@ -218,7 +219,7 @@ public:
 
    virtual ir_visitor_status visit(ir_dereference_variable *ir)
    {
-      if (_mesa_hash_table_search(locals, ir->var) == NULL) {
+      if (_mesa_set_search(locals, ir->var) == NULL) {
 	 /* The non-function variable must be a global, so try to find the
 	  * variable in the shader's symbol table.  If the variable is not
 	  * found, then it's a global that *MUST* be defined in the original
@@ -303,7 +304,7 @@ private:
    /**
     * Table of variables local to the function.
     */
-   hash_table *locals;
+   set *locals;
 };
 
 } /* anonymous namespace */
-- 
2.9.2



More information about the mesa-dev mailing list