Skip to content

Commit

Permalink
Replace a ForAll by manual execution.
Browse files Browse the repository at this point in the history
This reduces computation time of this part of the execution to 1/3 of
its previous value.
  • Loading branch information
markusbaumeister committed Mar 5, 2018
1 parent 2b65e2f commit bf83485
Showing 1 changed file with 16 additions and 8 deletions.
24 changes: 16 additions & 8 deletions gap/AttributeScheduler.gi
Original file line number Diff line number Diff line change
Expand Up @@ -96,19 +96,21 @@ end );
InstallMethod( ComputeProperty,
[ IsAttributeSchedulerGraph, IsFunction, IsObject ],
function( graph, property, object )
local all_names, how_to_compute, i, property_name, possibilities, max, j;
local all_names, how_to_compute, i, property_name, possibilities, max, j,
valid, k;

all_names := NamesOfComponents( graph );

how_to_compute := rec();

# It is slightly faster to keep the following loops separate
for i in all_names do
how_to_compute.( i ) := -1;
od;
for i in [ 1 .. Length( all_names ) ] do
if Tester( VALUE_GLOBAL( all_names[ i ] ) )( object ) then
how_to_compute.( all_names[ i ] ) := 0;

for i in all_names do
if Tester( VALUE_GLOBAL( i ) )( object ) then
how_to_compute.( i ) := 0;
fi;
od;

Expand All @@ -130,11 +132,17 @@ InstallMethod( ComputeProperty,

for j in [ 1 .. Length( possibilities ) ] do

if ForAll( possibilities[ j ], k -> how_to_compute.( k ) > -1 ) then

valid := true;
for k in possibilities[ j ] do
if how_to_compute.( k ) = -1 then
valid := false;
break;
fi;
od;

if valid then
how_to_compute.( all_names[ i ] ) := j;
break;

fi;

od;
Expand Down

0 comments on commit bf83485

Please sign in to comment.