From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 7871) id A8757385840A; Thu, 19 Oct 2023 14:41:11 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A8757385840A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1697726471; bh=T/VMVJD49Cliuz+K0JTIqgbrLS2hNBuiwk52crUxjIo=; h=From:To:Subject:Date:From; b=wEyA7C/VKgub3NkS+yHTXw1xjXM3HOSZCtF5M2IXYDBSz3jgG+35KUX9xsakpLS0h E/jzaAWJTw0SiQZU8RIc04xG37M9Dl2BWNsKdZMs4eX2aoxTA35bl61AGWHfSLzJyS U+E6WsVtIgZdGJvKJebfG8hflWZGc5Kq6zWgGftk= MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Marc Poulhi?s To: gcc-cvs@gcc.gnu.org Subject: [gcc r14-4750] ada: Seize opportunity to reuse List_Length X-Act-Checkin: gcc X-Git-Author: Ronan Desplanques X-Git-Refname: refs/heads/master X-Git-Oldrev: 7b1b787baa6ecc03a62b0db043a856cdb6463146 X-Git-Newrev: 0c29a990a645e24d48bf06adb7e1dca104b79335 Message-Id: <20231019144111.A8757385840A@sourceware.org> Date: Thu, 19 Oct 2023 14:41:11 +0000 (GMT) List-Id: https://gcc.gnu.org/g:0c29a990a645e24d48bf06adb7e1dca104b79335 commit r14-4750-g0c29a990a645e24d48bf06adb7e1dca104b79335 Author: Ronan Desplanques 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