Skip to content

Commit

Permalink
Merge branch 'mr/jicquel/github.PR#76' into 'master'
Browse files Browse the repository at this point in the history
Github PR#76: Prefer quantified expressions

See merge request eng/toolchain/gnatcoll-core!87
  • Loading branch information
Jicquel committed Mar 20, 2024
2 parents 35b6ab0 + f4dc8f7 commit abae75c
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 61 deletions.
28 changes: 11 additions & 17 deletions src/gnatcoll-json.adb
Original file line number Diff line number Diff line change
Expand Up @@ -1609,13 +1609,9 @@ package body GNATCOLL.JSON is
function Has_Field (Val : JSON_Value; Field : UTF8_String) return Boolean is
Vals : Object_Items_Pkg.Vector renames Val.Data.Obj_Value.Vals;
begin
for J in Vals.First_Index .. Vals.Last_Index loop
if Field = Vals.Element (J).Key then
return True;
end if;
end loop;

return False;
return
(for some J in Vals.First_Index .. Vals.Last_Index =>
Field = Vals.Element (J).Key);
end Has_Field;

---------
Expand Down Expand Up @@ -1748,16 +1744,14 @@ package body GNATCOLL.JSON is
then
return False;
else
for J in Left.Data.Arr_Value.Arr.Vals.First_Index ..
Left.Data.Arr_Value.Arr.Vals.Last_Index
loop
if not (Left.Data.Arr_Value.Arr.Vals (J) = -- recursive
Right.Data.Arr_Value.Arr.Vals (J))
then
return False;
end if;
end loop;
return True;
return
(for all J in
Left.Data.Arr_Value.Arr.Vals.First_Index ..
Left.Data.Arr_Value.Arr.Vals.Last_Index
=>
(Left.Data.Arr_Value.Arr.Vals (J) = -- recursive

Right.Data.Arr_Value.Arr.Vals (J)));
end if;

when JSON_Object_Type =>
Expand Down
14 changes: 2 additions & 12 deletions src/gnatcoll-strings_impl.adb
Original file line number Diff line number Diff line change
Expand Up @@ -2512,12 +2512,7 @@ package body GNATCOLL.Strings_Impl is

function Is_Upper (Self : XString) return Boolean is
begin
for C of Self loop
if C /= To_Upper (C) then
return False;
end if;
end loop;
return True;
return (for all C of Self => (C = To_Upper (C)));
end Is_Upper;

--------------
Expand All @@ -2526,12 +2521,7 @@ package body GNATCOLL.Strings_Impl is

function Is_Lower (Self : XString) return Boolean is
begin
for C of Self loop
if C /= To_Lower (C) then
return False;
end if;
end loop;
return True;
return (for all C of Self => (C = To_Lower (C)));
end Is_Lower;

end Strings;
Expand Down
15 changes: 5 additions & 10 deletions src/gnatcoll-utils.adb
Original file line number Diff line number Diff line change
Expand Up @@ -1098,16 +1098,11 @@ package body GNATCOLL.Utils is
-- pattern will consume a character from Str
-- (i.e next character in Pattern is not a ' * ').

for Index in S_I .. Str'Last loop
if Match
(Str (Index .. Str'Last),
Pattern (P_I .. Pattern'Last))
then
return True;
end if;
end loop;

return False;
return
(for some Index in S_I .. Str'Last =>
Match
(Str (Index .. Str'Last),
Pattern (P_I .. Pattern'Last)));

when others =>
Next_Str_Char;
Expand Down
13 changes: 4 additions & 9 deletions src/projects/gnatcoll-projects-normalize.adb
Original file line number Diff line number Diff line change
Expand Up @@ -436,15 +436,10 @@ package body GNATCOLL.Projects.Normalize is
Ext_Variable_Name;

when N_Variable_Reference =>
for J in Variable_Nodes'First .. Variable_Nodes_Last loop
if GPR.Tree.Name_Of (Node, Tree) =
GPR.Tree.Name_Of (Variable_Nodes (J), Tree)
then
return True;
end if;
end loop;

return False;
return
(for some J in Variable_Nodes'First .. Variable_Nodes_Last =>
GPR.Tree.Name_Of (Node, Tree) =
GPR.Tree.Name_Of (Variable_Nodes (J), Tree));

when others =>
return False;
Expand Down
15 changes: 2 additions & 13 deletions src/projects/gnatcoll-projects.adb
Original file line number Diff line number Diff line change
Expand Up @@ -3903,13 +3903,7 @@ package body GNATCOLL.Projects is
return True;
end if;

for T of Host_Targets_List loop
if T = Tgt then
return True;
end if;
end loop;

return False;
return (for some T of Host_Targets_List => T = Tgt);
end Target_Same_As_Host;

------------------
Expand Down Expand Up @@ -5409,12 +5403,7 @@ package body GNATCOLL.Projects is
Ext_Name : GPR.Name_Id) return Boolean
is
begin
for I in 1 .. Last - 1 loop
if UVs (I).Name = Ext_Name then
return False;
end if;
end loop;
return True;
return (for all I in 1 .. Last - 1 => (UVs (I).Name /= Ext_Name));
end Not_Already;

------------------
Expand Down

0 comments on commit abae75c

Please sign in to comment.