[pushed] Simplify ada_identical_enum_types_p

Message ID 20240826193039.104604-1-tromey@adacore.com
State New
Headers
Series [pushed] Simplify ada_identical_enum_types_p |

Checks

Context Check Description
linaro-tcwg-bot/tcwg_gdb_build--master-aarch64 warning Patch is already merged
linaro-tcwg-bot/tcwg_gdb_build--master-arm warning Patch is already merged

Commit Message

Tom Tromey Aug. 26, 2024, 7:30 p.m. UTC
  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 | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)
  

Patch

diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c
index 7853a482156..83794f97825 100644
--- a/gdb/ada-lang.c
+++ b/gdb/ada-lang.c
@@ -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;
     }