From 72ebc9ab33d608b4f229aef55adadb6d062f069c Mon Sep 17 00:00:00 2001 From: pjljvandelaar Date: Mon, 10 Jun 2024 20:38:16 +0200 Subject: [PATCH] Prefer usage of quantified expressions (#1238) Co-authored-by: Alejandro R. Mosteo --- src/alire/alire-crate_configuration.adb | 13 +++++-------- src/alire/alire-dependencies-graphs.adb | 8 +------- src/alire/alire-origins-deployers-system-apt.adb | 9 ++------- src/alire/alire-origins-deployers-system-zypper.adb | 10 +++------- src/alire/alire-properties-configurations.adb | 9 +++------ src/alire/alire-utils.adb | 10 +++------- src/alr/alr-utils.adb | 8 +------- 7 files changed, 18 insertions(+), 49 deletions(-) diff --git a/src/alire/alire-crate_configuration.adb b/src/alire/alire-crate_configuration.adb index c886c523..ba8eb43d 100644 --- a/src/alire/alire-crate_configuration.adb +++ b/src/alire/alire-crate_configuration.adb @@ -367,14 +367,11 @@ package body Alire.Crate_Configuration is is use Config_Maps; begin - for C in This.Var_Map.Iterate loop - if (Crate = "" or else Name (C).As_String = Crate) - and then Element (C).Set_By = Must_Be_Set - then - return False; - end if; - end loop; - return True; + return + (for all C in This.Var_Map.Iterate => + not + ((Crate = "" or else Name (C).As_String = Crate) + and then Element (C).Set_By = Must_Be_Set)); end Is_Config_Complete; --------------------- diff --git a/src/alire/alire-dependencies-graphs.adb b/src/alire/alire-dependencies-graphs.adb index 22b0dced..fa5a9027 100644 --- a/src/alire/alire-dependencies-graphs.adb +++ b/src/alire/alire-dependencies-graphs.adb @@ -72,13 +72,7 @@ package body Alire.Dependencies.Graphs is return Boolean is begin - for Dep of This loop - if +Dep.Dependent = Crate then - return True; - end if; - end loop; - - return False; + return (for some Dep of This => +Dep.Dependent = Crate); end Has_Dependencies; ----------- diff --git a/src/alire/alire-origins-deployers-system-apt.adb b/src/alire/alire-origins-deployers-system-apt.adb index 4f4db6ff..8406e7d7 100644 --- a/src/alire/alire-origins-deployers-system-apt.adb +++ b/src/alire/alire-origins-deployers-system-apt.adb @@ -25,13 +25,8 @@ package body Alire.Origins.Deployers.System.Apt is Valid_Exit_Codes => (0, 1), -- returned when not found Err_To_Out => True); begin - for Line of Output loop - if Line = "Status: install ok installed" then - return True; - end if; - end loop; - - return False; + return + (for some Line of Output => Line = "Status: install ok installed"); end Already_Installed; ------------ diff --git a/src/alire/alire-origins-deployers-system-zypper.adb b/src/alire/alire-origins-deployers-system-zypper.adb index fca28d6b..716ee622 100644 --- a/src/alire/alire-origins-deployers-system-zypper.adb +++ b/src/alire/alire-origins-deployers-system-zypper.adb @@ -30,13 +30,9 @@ package body Alire.Origins.Deployers.System.Zypper is Valid_Exit_Codes => (0, 104), -- returned when not found Err_To_Out => True); begin - for Line of Output loop - if Has_Prefix (Line, " + Has_Prefix (Line, " + This.Values.Item (Index).As_String = Str); end; when Real => diff --git a/src/alire/alire-utils.adb b/src/alire/alire-utils.adb index 1b48243d..fae78c29 100644 --- a/src/alire/alire-utils.adb +++ b/src/alire/alire-utils.adb @@ -16,13 +16,9 @@ package body Alire.Utils is function Command_Line_Contains (Prefix : String) return Boolean is begin - for I in 1 .. Ada.Command_Line.Argument_Count loop - if Has_Prefix (Ada.Command_Line.Argument (I), Prefix) then - return True; - end if; - end loop; - - return False; + return + (for some I in 1 .. Ada.Command_Line.Argument_Count => + Has_Prefix (Ada.Command_Line.Argument (I), Prefix)); end Command_Line_Contains; ------------- diff --git a/src/alr/alr-utils.adb b/src/alr/alr-utils.adb index 61f88396..cec9c53b 100644 --- a/src/alr/alr-utils.adb +++ b/src/alr/alr-utils.adb @@ -6,13 +6,7 @@ package body Alr.Utils is function Contains (V : AAA.Strings.Vector; Subst : String) return Boolean is begin - for Str of V loop - if AAA.Strings.Contains (Str, Subst) then - return True; - end if; - end loop; - - return False; + return (for some Str of V => AAA.Strings.Contains (Str, Subst)); end Contains; end Alr.Utils; -- 2.39.5