Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

prefer quantified expressions #127

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 1 addition & 6 deletions gpr/src/gpr-compilation-sync.adb
Original file line number Diff line number Diff line change
Expand Up @@ -196,12 +196,7 @@ package body GPR.Compilation.Sync is
function Match
(Name : String; R_Set : Regexp_Set) return Boolean is
begin
for Regexp of R_Set loop
if Match (Name, Regexp) then
return True;
end if;
end loop;
return False;
return (for some Regexp of R_Set => Match (Name, Regexp));
end Match;

S_Name : constant String := Simple_Name (File);
Expand Down
9 changes: 3 additions & 6 deletions gpr/src/gpr-conf.adb
Original file line number Diff line number Diff line change
Expand Up @@ -1422,12 +1422,9 @@ package body GPR.Conf is

function Is_Base_Name (Path : String) return Boolean is
begin
for I in Path'Range loop
if Path (I) = Directory_Separator or else Path (I) = '/' then
return False;
end if;
end loop;
return True;
return
(for all I in Path'Range =>
not (Path (I) = Directory_Separator or else Path (I) = '/'));
end Is_Base_Name;

-- Local Variables
Expand Down
21 changes: 6 additions & 15 deletions gpr/src/gpr-env.adb
Original file line number Diff line number Diff line change
Expand Up @@ -351,22 +351,13 @@ package body GPR.Env is
Last : constant Integer := Path'Last - Dir'Length + 1;

begin
for J in Path'First .. Last loop

-- Note: the order of the conditions below is important, since
-- it ensures a minimal number of string comparisons.

if (J = Path'First or else Path (J - 1) = Path_Separator)
return
(for some J in Path'First .. Last =>
(J = Path'First or else Path (J - 1) = Path_Separator)
and then
(J + Dir'Length > Path'Last
or else Path (J + Dir'Length) = Path_Separator)
and then Dir = Path (J .. J + Dir'Length - 1)
then
return True;
end if;
end loop;

return False;
(J + Dir'Length > Path'Last
or else Path (J + Dir'Length) = Path_Separator)
and then Dir = Path (J .. J + Dir'Length - 1));
end Is_Present;

-- Start of processing for Add_To_Path
Expand Down
41 changes: 14 additions & 27 deletions gpr/src/gpr-util.adb
Original file line number Diff line number Diff line change
Expand Up @@ -2217,22 +2217,16 @@ package body GPR.Util is

-- Definitely predefined if prefix is a- i- or s- followed by letter

if Name_Len >= 3
and then Name_Buffer (2) = '-'
and then (Name_Buffer (1) = 'a'
or else
Name_Buffer (1) = 'g'
or else
Name_Buffer (1) = 'i'
or else
Name_Buffer (1) = 's')
and then (Name_Buffer (3) in 'a' .. 'z'
or else
Name_Buffer (3) in 'A' .. 'Z')
if Name_Len >= 3 and then Name_Buffer (2) = '-'
and then
(Name_Buffer (1) = 'a' or else Name_Buffer (1) = 'g'
or else Name_Buffer (1) = 'i' or else Name_Buffer (1) = 's')
and then
(Name_Buffer (3) in 'a' .. 'z' or else Name_Buffer (3) in 'A' .. 'Z')
then
return True;

-- Definitely false if longer than 12 characters (8.3)
-- Definitely false if longer than 12 characters (8.3)

elsif Name_Len > 8 then
return False;
Expand All @@ -2241,17 +2235,13 @@ package body GPR.Util is
-- Otherwise check against special list, first padding to 8 characters

while Name_Len < 8 loop
Name_Len := Name_Len + 1;
Name_Len := Name_Len + 1;
Name_Buffer (Name_Len) := ' ';
end loop;

for J in Predef_Names'Range loop
if Name_Buffer (1 .. 8) = Predef_Names (J) then
return True;
end if;
end loop;

return False;
return
(for some J in Predef_Names'Range =>
Name_Buffer (1 .. 8) = Predef_Names (J));
end Is_Ada_Predefined_File_Name;

----------------------------
Expand Down Expand Up @@ -3969,12 +3959,9 @@ package body GPR.Util is

function Is_Base_Name (Path : String) return Boolean is
begin
for I in Path'Range loop
if Is_Directory_Separator (Path (I)) then
return False;
end if;
end loop;
return True;
return
(for all I in Path'Range =>
not (Is_Directory_Separator (Path (I))));
end Is_Base_Name;

RTS_Name : constant String := GPR.Conf.Runtime_Name_For (Language);
Expand Down
14 changes: 5 additions & 9 deletions gpr/src/gpr_build_util.adb
Original file line number Diff line number Diff line change
Expand Up @@ -1968,15 +1968,11 @@ package body Gpr_Build_Util is
function Is_Virtually_Empty return Boolean is
begin
if One_Queue_Per_Obj_Dir then
for J in Q_First .. Q.Last loop
if not Q.Table (J).Processed
and then Available_Obj_Dir (Q.Table (J).Info)
then
return False;
end if;
end loop;

return True;
return
(for all J in Q_First .. Q.Last =>
not
(not Q.Table (J).Processed
and then Available_Obj_Dir (Q.Table (J).Info)));

else
return Is_Empty;
Expand Down
7 changes: 1 addition & 6 deletions src/gprslave.adb
Original file line number Diff line number Diff line change
Expand Up @@ -579,12 +579,7 @@ procedure Gprslave is

function Working_Dir_Exists (Directory : String) return Boolean is
begin
for B of Builders loop
if Work_Directory (B) = Directory then
return True;
end if;
end loop;
return False;
return (for some B of Builders => Work_Directory (B) = Directory);
end Working_Dir_Exists;

end Builders;
Expand Down