On 11/17/2011 04:21 PM, Dodji Seketeli wrote:
+      parm = TREE_VALUE (parm_desc);
+      if (TREE_CODE (parm) == TYPE_DECL)
+       val = iterative_hash_template_parm_index_no_level
+         (TEMPLATE_TYPE_PARM_INDEX (TREE_TYPE (parm)), val);
+      else if (TREE_CODE (parm) == TEMPLATE_DECL)
+       val = iterative_hash_template_parms
+         (INNERMOST_TEMPLATE_PARMS (DECL_TEMPLATE_PARMS (parm)), val);
+      else if (TREE_CODE (parm) == PARM_DECL)
+       val = iterative_hash_template_parm_index_no_level
+         (DECL_INITIAL (parm), val);

It looks like type and non-type parameters will get the same hash here. You also need to hash the type of a non-type parameter, so that two non-type parameters of different types are considered different.

And I don't see any strategy for dealing with hash collisions.

How about if we just store a pointer to the template parameter list and do comp_template_parms? Since we normally use TYPE_CANONICAL to compare template parameters, this shouldn't be a significant bottleneck. If canonical_type_parameter gets slow we can mess with hashes there instead of the current O(N) linked list lookup.

Jason

Reply via email to