public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [COMMITTED] ada: Remove redundant guard against empty list of actions
@ 2024-05-07  8:00 Marc Poulhiès
  0 siblings, 0 replies; only message in thread
From: Marc Poulhiès @ 2024-05-07  8:00 UTC (permalink / raw)
  To: gcc-patches; +Cc: Piotr Trojanek

From: Piotr Trojanek <trojanek@adacore.com>

Code cleanup.

gcc/ada/

	* exp_ch4.adb (Useful): Remove redundant check for empty list,
	because iteration with First works also for empty list; rename
	local variable from L to Action.

Tested on x86_64-pc-linux-gnu, committed on master.

---
 gcc/ada/exp_ch4.adb | 25 +++++++++++--------------
 1 file changed, 11 insertions(+), 14 deletions(-)

diff --git a/gcc/ada/exp_ch4.adb b/gcc/ada/exp_ch4.adb
index 5fa47c9b6e7..505c4b3151a 100644
--- a/gcc/ada/exp_ch4.adb
+++ b/gcc/ada/exp_ch4.adb
@@ -12930,8 +12930,7 @@ package body Exp_Ch4 is
       --  to Opnd /= Shortcut_Value.
 
       function Useful (Actions : List_Id) return Boolean;
-      --  Return True if Actions is not empty and contains useful nodes to
-      --  process.
+      --  Return True if Actions contains useful nodes to process
 
       --------------------
       -- Make_Test_Expr --
@@ -12951,22 +12950,20 @@ package body Exp_Ch4 is
       ------------
 
       function Useful (Actions : List_Id) return Boolean is
-         L : Node_Id;
+         Action : Node_Id;
       begin
-         if Present (Actions) then
-            L := First (Actions);
+         Action := First (Actions);
 
-            --  For now "useful" means not N_Variable_Reference_Marker.
-            --  Consider stripping other nodes in the future.
+         --  For now "useful" means not N_Variable_Reference_Marker. Consider
+         --  stripping other nodes in the future.
 
-            while Present (L) loop
-               if Nkind (L) /= N_Variable_Reference_Marker then
-                  return True;
-               end if;
+         while Present (Action) loop
+            if Nkind (Action) /= N_Variable_Reference_Marker then
+               return True;
+            end if;
 
-               Next (L);
-            end loop;
-         end if;
+            Next (Action);
+         end loop;
 
          return False;
       end Useful;
-- 
2.43.2


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

only message in thread, other threads:[~2024-05-07  8:00 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-05-07  8:00 [COMMITTED] ada: Remove redundant guard against empty list of actions Marc Poulhiès

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).