public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
From: Pierre-Marie de Rodat <pmderodat@gcc.gnu.org>
To: gcc-cvs@gcc.gnu.org
Subject: [gcc r12-6467] [Ada] Avoid redundant checks for empty lists
Date: Tue, 11 Jan 2022 13:28:21 +0000 (GMT)	[thread overview]
Message-ID: <20220111132821.26D7A38A941E@sourceware.org> (raw)

https://gcc.gnu.org/g:9d4a5ddc7b124f201d7c6746e07b0ad98be5f702

commit r12-6467-g9d4a5ddc7b124f201d7c6746e07b0ad98be5f702
Author: Piotr Trojanek <trojanek@adacore.com>
Date:   Thu Jan 6 19:14:33 2022 +0100

    [Ada] Avoid redundant checks for empty lists
    
    gcc/ada/
    
            * exp_ch4.adb (Expand_N_Expression_With_Actions): Avoid
            redundant check.
            * exp_ch5.adb (Expand_N_If_Statement): Likewise.
            * exp_ch7.adb (Process_Declarations): Likewise.
            * sem_elab.adb (Freeze_Node_Location): Likewise.
            * exp_util.adb (Insert_Actions): Likewise.
            (Is_OK_PF_Pragma): Likewise.
            (Requires_Cleanup_Actions): Remove early exit; ordinary
            processing path will similarly do nothing.

Diff:
---
 gcc/ada/exp_ch4.adb  | 2 +-
 gcc/ada/exp_ch5.adb  | 4 +---
 gcc/ada/exp_ch7.adb  | 2 +-
 gcc/ada/exp_util.adb | 8 ++------
 gcc/ada/sem_elab.adb | 2 +-
 5 files changed, 6 insertions(+), 12 deletions(-)

diff --git a/gcc/ada/exp_ch4.adb b/gcc/ada/exp_ch4.adb
index 18f0f746cae..c31f5bb36ba 100644
--- a/gcc/ada/exp_ch4.adb
+++ b/gcc/ada/exp_ch4.adb
@@ -5697,7 +5697,7 @@ package body Exp_Ch4 is
       --  Do not evaluate the expression when there are no actions because the
       --  expression_with_actions node will be replaced by the expression.
 
-      elsif No (Acts) or else Is_Empty_List (Acts) then
+      elsif Is_Empty_List (Acts) then
          null;
 
       --  Force the evaluation of the expression by capturing its value in a
diff --git a/gcc/ada/exp_ch5.adb b/gcc/ada/exp_ch5.adb
index daf86522966..b38e3f54f67 100644
--- a/gcc/ada/exp_ch5.adb
+++ b/gcc/ada/exp_ch5.adb
@@ -4475,9 +4475,7 @@ package body Exp_Ch5 is
             --  entire if statement by the sequence of else statements.
 
             if No (Elsif_Parts (N)) then
-               if No (Else_Statements (N))
-                 or else Is_Empty_List (Else_Statements (N))
-               then
+               if Is_Empty_List (Else_Statements (N)) then
                   Rewrite (N,
                     Make_Null_Statement (Sloc (N)));
                else
diff --git a/gcc/ada/exp_ch7.adb b/gcc/ada/exp_ch7.adb
index 57b381c960a..d7863c30b68 100644
--- a/gcc/ada/exp_ch7.adb
+++ b/gcc/ada/exp_ch7.adb
@@ -2249,7 +2249,7 @@ package body Exp_Ch7 is
       --  Start of processing for Process_Declarations
 
       begin
-         if No (Decls) or else Is_Empty_List (Decls) then
+         if Is_Empty_List (Decls) then
             return;
          end if;
 
diff --git a/gcc/ada/exp_util.adb b/gcc/ada/exp_util.adb
index e1b462ac05f..aa470724815 100644
--- a/gcc/ada/exp_util.adb
+++ b/gcc/ada/exp_util.adb
@@ -7172,7 +7172,7 @@ package body Exp_Util is
       Wrapped_Node : Node_Id := Empty;
 
    begin
-      if No (Ins_Actions) or else Is_Empty_List (Ins_Actions) then
+      if Is_Empty_List (Ins_Actions) then
          return;
       end if;
 
@@ -9963,7 +9963,7 @@ package body Exp_Util is
             --  Nothing to do when the pragma lacks arguments, in which case it
             --  is illegal.
 
-            elsif No (Args) or else Is_Empty_List (Args) then
+            elsif Is_Empty_List (Args) then
                return False;
             end if;
 
@@ -12674,10 +12674,6 @@ package body Exp_Util is
       Typ     : Entity_Id;
 
    begin
-      if No (L) or else Is_Empty_List (L) then
-         return False;
-      end if;
-
       Decl := First (L);
       while Present (Decl) loop
 
diff --git a/gcc/ada/sem_elab.adb b/gcc/ada/sem_elab.adb
index a4212786f68..8e38f8c1285 100644
--- a/gcc/ada/sem_elab.adb
+++ b/gcc/ada/sem_elab.adb
@@ -15382,7 +15382,7 @@ package body Sem_Elab is
 
                elsif Present (Vis_Decls)
                  and then List_Containing (FNode) = Vis_Decls
-                 and then (No (Prv_Decls) or else Is_Empty_List (Prv_Decls))
+                 and then Is_Empty_List (Prv_Decls)
                then
                   null;


                 reply	other threads:[~2022-01-11 13:28 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=20220111132821.26D7A38A941E@sourceware.org \
    --to=pmderodat@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).