about summary refs log tree commit diff stats
path: root/030container.cc
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2016-09-10 09:59:32 -0700
committerKartik K. Agaram <vc@akkartik.com>2016-09-10 09:59:32 -0700
commit3cfa56a923e2ff96c01ba932ecc9cc4ec38e616d (patch)
tree14091a2e015687e8c3143d9451ea357c9d1f4b5b /030container.cc
parent7303b27fe555644daf45b89e9feb1908f1f085e4 (diff)
downloadmu-3cfa56a923e2ff96c01ba932ecc9cc4ec38e616d.tar.gz
3313
Allow type-trees to be ordered in some consistent fashion. This could be
quite inefficient since we often end up comparing the four sub-trees of
the two arguments in 4 different ways. So far it isn't much of a time
sink.
Diffstat (limited to '030container.cc')
-rw-r--r--030container.cc18
1 files changed, 5 insertions, 13 deletions
diff --git a/030container.cc b/030container.cc
index bb7ce08f..33552ee8 100644
--- a/030container.cc
+++ b/030container.cc
@@ -194,34 +194,26 @@ void compute_container_sizes(reagent& r) {
   if (is_literal(r) || is_dummy(r)) return;
   reagent rcopy = r;
   // Compute Container Size(reagent rcopy)
-  set<string> pending_metadata;
+  set<type_tree> pending_metadata;  // might actually be faster to just convert to string rather than compare type_tree directly; so far the difference is negligible
   compute_container_sizes(rcopy.type, pending_metadata);
   if (contains_key(Container_metadata, rcopy.type))
     r.metadata = get(Container_metadata, rcopy.type);
 }
 
-void compute_container_sizes(const type_tree* type, set<string>& pending_metadata) {
+void compute_container_sizes(const type_tree* type, set<type_tree>& pending_metadata) {
   if (!type) return;
   trace(9993, "transform") << "compute container sizes for " << to_string(type) << end();
   if (contains_key(Container_metadata, type)) return;
-  if (contains_key(pending_metadata, names_to_string_without_quotes(type))) return;
-  pending_metadata.insert(names_to_string_without_quotes(type));
-//?   cerr << to_string(type) << '\n';
+  if (contains_key(pending_metadata, *type)) return;
+  pending_metadata.insert(*type);
   if (!type->atom) {
     assert(type->left->atom);
     if (type->left->name == "address") {
-//?       cerr << "  address\n";
       compute_container_sizes(type->right, pending_metadata);
     }
     else if (type->left->name == "array") {
       const type_tree* element_type = type->right;
       // hack: support both array:number:3 and array:address:number
-//?       cerr << "  array\n";
-//?       cerr << "    " << to_string(type) << '\n';
-//?       cerr << "    " << to_string(element_type) << ' ' << element_type->atom << ' ' << element_type->right;
-//?       if (element_type->right)
-//?         cerr << " -- " << to_string(element_type->right) << ' ' << element_type->right->atom << ' ' << is_integer(element_type->right->name);
-//?       cerr << '\n';
       if (!element_type->atom && element_type->right && element_type->right->atom && is_integer(element_type->right->name))
         element_type = element_type->left;
       compute_container_sizes(element_type, pending_metadata);
@@ -238,7 +230,7 @@ void compute_container_sizes(const type_tree* type, set<string>& pending_metadat
   // End compute_container_sizes Atom Cases
 }
 
-void compute_container_sizes(const type_info& container_info, const type_tree* full_type, set<string>& pending_metadata) {
+void compute_container_sizes(const type_info& container_info, const type_tree* full_type, set<type_tree>& pending_metadata) {
   assert(container_info.kind == CONTAINER);
   // size of a container is the sum of the sizes of its element
   // (So it can only contain arrays if they're static and include their