@@ -1078,6 +1078,11 @@ function propagate_constraints!(graph::Graph, sources::Set{Int} = Set{Int}(); lo
10781078
10791079 seen = copy (staged)
10801080
1081+ # Pre-allocate workspace for added constraints
1082+ max_spp = maximum (spp, init = 0 )
1083+ added_constr1 = BitVector (undef, max_spp)
1084+ old_gconstr1 = BitVector (undef, max_spp)
1085+
10811086 while ! isempty (staged)
10821087 staged_next = Set {Int} ()
10831088 for p0 in staged
@@ -1091,16 +1096,28 @@ function propagate_constraints!(graph::Graph, sources::Set{Int} = Set{Int}(); lo
10911096 pkgs[p1] == uuid_julia && continue
10921097
10931098 msk = gmsk[p0][j1]
1094- # consider the sub-mask with only allowed versions of p0
1095- sub_msk = msk[:,gconstr0]
10961099 # if an entire row of the sub-mask is false, that version of p1
10971100 # is effectively forbidden
10981101 # (this is just like calling `any` row-wise)
1099- added_constr1 = any! (BitVector (undef, spp[p1]), sub_msk)
1102+ # sub_msk = msk[:, gconstr0]
1103+ # added_constr1 = any!(BitVector(undef, spp[p1]), sub_msk)
1104+ # The code below is equivalent to the shorter code above, but avoids allocating
1105+ spp1 = spp[p1]
1106+ resize! (added_constr1, spp1)
1107+ fill! (added_constr1, false )
1108+ for v1 in 1 : spp1
1109+ for v0 in 1 : spp[p0]
1110+ if gconstr0[v0] && msk[v1, v0]
1111+ added_constr1[v1] = true
1112+ break
1113+ end
1114+ end
1115+ end
1116+
11001117 # apply the new constraints, checking for contradictions
11011118 # (keep the old ones for comparison)
11021119 gconstr1 = gconstr[p1]
1103- old_gconstr1 = copy ( gconstr1)
1120+ copy! (old_gconstr1, gconstr1)
11041121 gconstr1 .&= added_constr1
11051122 # if the new constraints are more restrictive than the
11061123 # previous ones, record it and propagate them next
0 commit comments