public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
From: Marc Poulhi?s <dkm@gcc.gnu.org>
To: gcc-cvs@gcc.gnu.org
Subject: [gcc r14-4750] ada: Seize opportunity to reuse List_Length
Date: Thu, 19 Oct 2023 14:41:11 +0000 (GMT)	[thread overview]
Message-ID: <20231019144111.A8757385840A@sourceware.org> (raw)

https://gcc.gnu.org/g:0c29a990a645e24d48bf06adb7e1dca104b79335

commit r14-4750-g0c29a990a645e24d48bf06adb7e1dca104b79335
Author: Ronan Desplanques <desplanques@adacore.com>
Date:   Fri Sep 29 11:25:18 2023 +0200

    ada: Seize opportunity to reuse List_Length
    
    This patch is intended as a readability improvement. It doesn't
    change the behavior of the compiler.
    
    gcc/ada/
    
            * sem_ch3.adb (Constrain_Array): Replace manual list length
            computation by call to List_Length.

Diff:
---
 gcc/ada/sem_ch3.adb | 8 +-------
 1 file changed, 1 insertion(+), 7 deletions(-)

diff --git a/gcc/ada/sem_ch3.adb b/gcc/ada/sem_ch3.adb
index c79d323395f3..e92b46fa6f6f 100644
--- a/gcc/ada/sem_ch3.adb
+++ b/gcc/ada/sem_ch3.adb
@@ -13809,7 +13809,7 @@ package body Sem_Ch3 is
       Suffix      : Character)
    is
       C                     : constant Node_Id := Constraint (SI);
-      Number_Of_Constraints : Nat := 0;
+      Number_Of_Constraints : constant Nat := List_Length (Constraints (C));
       Index                 : Node_Id;
       S, T                  : Entity_Id;
       Constraint_OK         : Boolean := True;
@@ -13835,12 +13835,6 @@ package body Sem_Ch3 is
          Constraint_OK := False;
 
       else
-         S := First (Constraints (C));
-         while Present (S) loop
-            Number_Of_Constraints := Number_Of_Constraints + 1;
-            Next (S);
-         end loop;
-
          --  In either case, the index constraint must provide a discrete
          --  range for each index of the array type and the type of each
          --  discrete range must be the same as that of the corresponding

                 reply	other threads:[~2023-10-19 14:41 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20231019144111.A8757385840A@sourceware.org \
    --to=dkm@gcc.gnu.org \
    --cc=gcc-cvs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).