Skip to content

Commit

Permalink
Instead of multiple setter calls, set filters and attribute in one.
Browse files Browse the repository at this point in the history
To avoid deductions changing the type all the time.
  • Loading branch information
hulpke committed Apr 28, 2018
1 parent ce7879a commit 0f114a4
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions lib/coll.gi
Original file line number Diff line number Diff line change
Expand Up @@ -3058,13 +3058,21 @@ InstallMethod( CanComputeIsSubset,"default: no, unless identical",
InstallOtherMethod(SetSize,true,[IsObject and IsAttributeStoringRep,IsObject],
100, # override system setter
function(obj,sz)
if not HasSize(obj) then
SetIsEmpty(obj,sz=0);
SetIsTrivial(obj,sz=1);
SetIsNonTrivial(obj,sz<>1);
SetIsFinite(obj,sz<>infinity);
local filt;
if HasSize(obj) and Size(obj)<>sz then
# Make this an ordinary error to enter break loop so that one can
# investigate call order for debugging
Error("size of ",obj," already set to ",Size(obj),
", cannot be changed to ",sz);
fi;
TryNextMethod(); # to enforce size setting
if sz=0 then filt:=IsEmpty;
elif sz=1 then filt:=IsTrivial;
elif sz=infinity then filt:=IsNonTrivial and HasIsFinite;
else filt:=IsNonTrivial and IsFinite;
fi;
filt:=filt and HasSize;
obj!.Size:=sz;
SetFilterObj(obj,filt);
end);

#############################################################################
Expand Down

0 comments on commit 0f114a4

Please sign in to comment.