public inbox for gdb-cvs@sourceware.org
help / color / mirror / Atom feed
* [binutils-gdb] Use bool and early loop exit in remove_extra_symbols
@ 2023-05-12 19:29 Tom Tromey
  0 siblings, 0 replies; only message in thread
From: Tom Tromey @ 2023-05-12 19:29 UTC (permalink / raw)
  To: gdb-cvs

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=44a37a985325184e36743685ce496b042da7a816

commit 44a37a985325184e36743685ce496b042da7a816
Author: Tom Tromey <tromey@adacore.com>
Date:   Tue Apr 4 09:27:29 2023 -0600

    Use bool and early loop exit in remove_extra_symbols
    
    This changes remove_extra_symbols to use bool rather than int, and
    changes the nested loops to exit early when "remove_p" is set.

Diff:
---
 gdb/ada-lang.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c
index 403f404ca09..b54ef19ad6a 100644
--- a/gdb/ada-lang.c
+++ b/gdb/ada-lang.c
@@ -5039,7 +5039,7 @@ remove_extra_symbols (std::vector<struct block_symbol> &syms)
   i = 0;
   while (i < syms.size ())
     {
-      int remove_p = 0;
+      bool remove_p = false;
 
       /* If two symbols have the same name and one of them is a stub type,
 	 the get rid of the stub.  */
@@ -5047,14 +5047,14 @@ remove_extra_symbols (std::vector<struct block_symbol> &syms)
       if (syms[i].symbol->type ()->is_stub ()
 	  && syms[i].symbol->linkage_name () != NULL)
 	{
-	  for (j = 0; j < syms.size (); j++)
+	  for (j = 0; !remove_p && j < syms.size (); j++)
 	    {
 	      if (j != i
 		  && !syms[j].symbol->type ()->is_stub ()
 		  && syms[j].symbol->linkage_name () != NULL
 		  && strcmp (syms[i].symbol->linkage_name (),
 			     syms[j].symbol->linkage_name ()) == 0)
-		remove_p = 1;
+		remove_p = true;
 	    }
 	}
 
@@ -5065,7 +5065,7 @@ remove_extra_symbols (std::vector<struct block_symbol> &syms)
 	  && syms[i].symbol->aclass () == LOC_STATIC
 	  && is_nondebugging_type (syms[i].symbol->type ()))
 	{
-	  for (j = 0; j < syms.size (); j += 1)
+	  for (j = 0; !remove_p && j < syms.size (); j += 1)
 	    {
 	      if (i != j
 		  && syms[j].symbol->linkage_name () != NULL
@@ -5075,7 +5075,7 @@ remove_extra_symbols (std::vector<struct block_symbol> &syms)
 		      == syms[j].symbol->aclass ())
 		  && syms[i].symbol->value_address ()
 		  == syms[j].symbol->value_address ())
-		remove_p = 1;
+		remove_p = true;
 	    }
 	}

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2023-05-12 19:29 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-05-12 19:29 [binutils-gdb] Use bool and early loop exit in remove_extra_symbols Tom Tromey

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).