From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2126) id A04D33858401; Fri, 12 May 2023 19:29:07 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A04D33858401 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1683919747; bh=RrdkmvEyk6PpDrWGufKuPzgY7bP0JitlieqtGXAtu8g=; h=From:To:Subject:Date:From; b=Y21ypZr/vhEGK1HtO36vkLZhsGggLT2RvxAqUjW5xErKrsMQS90bwnFRSOedKo5uH kSoNjB+z8nQlD5HbDNuWL1XNlN8W+9SXqa82Q8juf6zeXRfNKCGKyiiSVIPUY6/66c 4jMxBIXV4PvD3TDV7Vp36nKrRpIy6cpwDD01Pw9Q= Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Tom Tromey To: gdb-cvs@sourceware.org Subject: [binutils-gdb] Use bool and early loop exit in remove_extra_symbols X-Act-Checkin: binutils-gdb X-Git-Author: Tom Tromey X-Git-Refname: refs/heads/master X-Git-Oldrev: ff4631e22bfc5d6a76b8d5520abbf0c9c2a57cd4 X-Git-Newrev: 44a37a985325184e36743685ce496b042da7a816 Message-Id: <20230512192907.A04D33858401@sourceware.org> Date: Fri, 12 May 2023 19:29:07 +0000 (GMT) List-Id: https://sourceware.org/git/gitweb.cgi?p=3Dbinutils-gdb.git;h=3D44a37a985325= 184e36743685ce496b042da7a816 commit 44a37a985325184e36743685ce496b042da7a816 Author: Tom Tromey Date: Tue Apr 4 09:27:29 2023 -0600 Use bool and early loop exit in remove_extra_symbols =20 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 &syms) i =3D 0; while (i < syms.size ()) { - int remove_p =3D 0; + bool remove_p =3D false; =20 /* 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 &syms) if (syms[i].symbol->type ()->is_stub () && syms[i].symbol->linkage_name () !=3D NULL) { - for (j =3D 0; j < syms.size (); j++) + for (j =3D 0; !remove_p && j < syms.size (); j++) { if (j !=3D i && !syms[j].symbol->type ()->is_stub () && syms[j].symbol->linkage_name () !=3D NULL && strcmp (syms[i].symbol->linkage_name (), syms[j].symbol->linkage_name ()) =3D=3D 0) - remove_p =3D 1; + remove_p =3D true; } } =20 @@ -5065,7 +5065,7 @@ remove_extra_symbols (std::vector &syms) && syms[i].symbol->aclass () =3D=3D LOC_STATIC && is_nondebugging_type (syms[i].symbol->type ())) { - for (j =3D 0; j < syms.size (); j +=3D 1) + for (j =3D 0; !remove_p && j < syms.size (); j +=3D 1) { if (i !=3D j && syms[j].symbol->linkage_name () !=3D NULL @@ -5075,7 +5075,7 @@ remove_extra_symbols (std::vector &syms) =3D=3D syms[j].symbol->aclass ()) && syms[i].symbol->value_address () =3D=3D syms[j].symbol->value_address ()) - remove_p =3D 1; + remove_p =3D true; } }