From de6c9faabbf7e61defac013a377186b4ae24da46 Mon Sep 17 00:00:00 2001 From: pjljvandelaar Date: Wed, 12 Jun 2024 13:57:08 +0200 Subject: [PATCH] Refactor: prefer membership tests (#1243) Co-authored-by: Alejandro R. Mosteo --- src/alire/alire-expressions-maps.adb | 7 ++++--- src/alire/alire-expressions.ads | 9 ++++----- src/alire/alire-properties-actions-runners.ads | 2 +- src/alire/alire-vcss-git.adb | 2 +- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/alire/alire-expressions-maps.adb b/src/alire/alire-expressions-maps.adb index 3069c2e2..0b7b4473 100644 --- a/src/alire/alire-expressions-maps.adb +++ b/src/alire/alire-expressions-maps.adb @@ -7,12 +7,13 @@ package body Alire.Expressions.Maps is procedure Insert (M : in out Map; V : String; E : Elements) is begin - if V = TOML_Keys.Case_Others or else V = "others" then + if V in TOML_Keys.Case_Others | "others" then M.Set_Others (E); else if not M.Base.Is_Valid (V) and then Force then - Trace.Debug ("Storing unknown value '" & V & "' for enumeration '" - & Key (M.Base) & "'"); + Trace.Debug + ("Storing unknown value '" & V & "' for enumeration '" & + Key (M.Base) & "'"); end if; M.Entries.Insert (V, E); end if; diff --git a/src/alire/alire-expressions.ads b/src/alire/alire-expressions.ads index ee1d5e92..7abcf988 100644 --- a/src/alire/alire-expressions.ads +++ b/src/alire/alire-expressions.ads @@ -30,11 +30,10 @@ package Alire.Expressions with Preelaborate is function Name (This : Variable) return String; -- The Ada-like name of this variable - function Satisfies (Property : Properties.Property'Class; - Var_Key : String; - Value : String) return Boolean - with Pre => Value /= TOML_Keys.Case_Others and then - Value /= "others"; + function Satisfies + (Property : Properties.Property'Class; Var_Key : String; Value : String) + return Boolean with + Pre => Value not in TOML_Keys.Case_Others | "others"; -- Say if a property is satisfied by the value, which must match the -- Variable and property type (keys must match). Doesn't accept defaults. diff --git a/src/alire/alire-properties-actions-runners.ads b/src/alire/alire-properties-actions-runners.ads index 5dd745e4..cfada5ed 100644 --- a/src/alire/alire-properties-actions-runners.ads +++ b/src/alire/alire-properties-actions-runners.ads @@ -37,7 +37,7 @@ private Working_Folder : Any_Path (1 .. Folder_Len); end record with Type_Invariant => - (Name = "" or else Name in Action_Name) + (Name in "" | Action_Name) and then (if Moment = On_Demand then Name /= ""); diff --git a/src/alire/alire-vcss-git.adb b/src/alire/alire-vcss-git.adb index 890374b0..f819ac36 100644 --- a/src/alire/alire-vcss-git.adb +++ b/src/alire/alire-vcss-git.adb @@ -484,7 +484,7 @@ package body Alire.VCSs.Git is -- Prepare Ref to make it less ambiguous - if Ref = "HEAD" or else Ref = "" then + if Ref in "HEAD" | "" then return This.Remote_Commit (From, ASCII.HT & "HEAD"); elsif Ref (Ref'First) not in '/' | ASCII.HT then return This.Remote_Commit (From, '/' & Ref); -- 2.39.5