diff mbox

[C++] METHOD_VEC sorting

Message ID 47a002a0-cc67-d264-2efb-9d081e7ee907@acm.org
State New
Headers show

Commit Message

Nathan Sidwell Aug. 25, 2017, 12:29 p.m. UTC
While I intend to kill METHOD_VEC, I noticed its comparison function 
contemplated functions with NULL DECL_NAMEs.  Those aren't a thing.

applied to trunk.

nathan
diff mbox

Patch

2017-08-25  Nathan Sidwell  <nathan@acm.org>

	* class.c (method_name_cmp, resort_method_name_cmp): Method names
	can never be NULL.

Index: class.c
===================================================================
--- class.c	(revision 251348)
+++ class.c	(working copy)
@@ -2263,12 +2263,6 @@  method_name_cmp (const void* m1_p, const
   const tree *const m1 = (const tree *) m1_p;
   const tree *const m2 = (const tree *) m2_p;
 
-  if (*m1 == NULL_TREE && *m2 == NULL_TREE)
-    return 0;
-  if (*m1 == NULL_TREE)
-    return -1;
-  if (*m2 == NULL_TREE)
-    return 1;
   if (OVL_NAME (*m1) < OVL_NAME (*m2))
     return -1;
   return 1;
@@ -2282,20 +2276,13 @@  resort_method_name_cmp (const void* m1_p
 {
   const tree *const m1 = (const tree *) m1_p;
   const tree *const m2 = (const tree *) m2_p;
-  if (*m1 == NULL_TREE && *m2 == NULL_TREE)
-    return 0;
-  if (*m1 == NULL_TREE)
+
+  tree n1 = OVL_NAME (*m1);
+  tree n2 = OVL_NAME (*m2);
+  resort_data.new_value (&n1, resort_data.cookie);
+  resort_data.new_value (&n2, resort_data.cookie);
+  if (n1 < n2)
     return -1;
-  if (*m2 == NULL_TREE)
-    return 1;
-  {
-    tree d1 = OVL_NAME (*m1);
-    tree d2 = OVL_NAME (*m2);
-    resort_data.new_value (&d1, resort_data.cookie);
-    resort_data.new_value (&d2, resort_data.cookie);
-    if (d1 < d2)
-      return -1;
-  }
   return 1;
 }