]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
Simplify ada_identical_enum_types_p
authorTom Tromey <tromey@adacore.com>
Mon, 26 Aug 2024 19:29:04 +0000 (13:29 -0600)
committerTom Tromey <tromey@adacore.com>
Mon, 26 Aug 2024 19:29:04 +0000 (13:29 -0600)
This patch changes ada_identical_enum_types_p to reuse the field names
that are computed earlier in the loop.  This is a simple cleanup, but
also is useful for a larger change that I'm working on.

Tested on x86-64 Fedora 38.

gdb/ada-lang.c

index 7853a482156eaab71609b4b5395c3a4ab6d5f54a..83794f97825cda5df4b11ee2f2784c6f035005e6 100644 (file)
@@ -4996,12 +4996,9 @@ ada_identical_enum_types_p (struct type *type1, struct type *type2)
       int len_1 = strlen (name_1);
       int len_2 = strlen (name_2);
 
-      ada_remove_trailing_digits (type1->field (i).name (), &len_1);
-      ada_remove_trailing_digits (type2->field (i).name (), &len_2);
-      if (len_1 != len_2
-         || strncmp (type1->field (i).name (),
-                     type2->field (i).name (),
-                     len_1) != 0)
+      ada_remove_trailing_digits (name_1, &len_1);
+      ada_remove_trailing_digits (name_2, &len_2);
+      if (len_1 != len_2 || strncmp (name_1, name_2, len_1) != 0)
        return 0;
     }