Skip to content

Commit

Permalink
Fix hashing for integer plists (#5807)
Browse files Browse the repository at this point in the history
  • Loading branch information
fingolfin authored Oct 11, 2024
1 parent 56b9f5e commit 19484a7
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/dicthf.gi
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ function(m, v)
if not IsPlistRep(x) then
x := AsPlist(x);
fi;
return HashKeyWholeBag(x, 1);
return HashKeyBag(x, 1, 0, Length(x) * GAPInfo.BytesPerVariable);
end;

# alternative code w/o HashKeyBag
Expand Down
20 changes: 20 additions & 0 deletions tst/testbugfix/2024-10-11-orbit-hash.tst
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Fix a bug reported by Leonard Soicher caused by a bug in
# the hash function for lists of small positive integers.
gap> n:=280;;
gap> G:=OnePrimitiveGroup(NrMovedPoints,n,Size,604800*2);
J_2.2
gap> blocks := [ [ 1, 2, 3, 28, 108, 119, 155, 198, 216, 226 ],
> [ 1, 2, 3, 118, 119, 140, 193, 213, 218, 226 ] ];;
gap> Append(blocks[2],[1..1000]); for i in [1..1000] do Remove(blocks[2]); od;
gap> Append(blocks[2],[1..1000]); for i in [1..1000] do Remove(blocks[2]); od;
gap> ForAll(blocks,IsSet);
true
gap> orb1:=Orbit(G,blocks[1],OnSets);;
gap> Length(orb1);
12096
gap> orb2:=Orbit(G,blocks[2],OnSets);;
gap> Length(orb2);
1008
gap> orbs:=Orbits(G,blocks,OnSets);;
gap> List(orbs,Length); # this code gave wrong results
[ 12096, 1008 ]

0 comments on commit 19484a7

Please sign in to comment.