Skip to content

Commit 96c73b4

Browse files
authored
Remove AsPlist (#6327)
This was almost the same as PlainListCopy, but slower. Since it was an undocumented internal helper and not used in any package, we simply remove it.
1 parent 050739d commit 96c73b4

File tree

10 files changed

+48
-83
lines changed

10 files changed

+48
-83
lines changed

hpcgap/demo/orbit2.g

Lines changed: 33 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,12 @@
99
# For the actually new points and their ids act on them by all the generators
1010
# make a list of triples: pt, parent id, gen used and cut it into blocks of
1111
# some suitable size. Run task on each block
12-
12+
1313
#
1414

1515
#
1616
# dict is a thread-safe data structure (blocked hash table perhaps)
17-
# it supports AddOrLookup(dict, obj)
17+
# it supports AddOrLookup(dict, obj)
1818
# if obj is in dict already, it returns the id assigned when obj was added
1919
# if obj is not already in dict, it returns -(a new id)
2020
# The IDs are small positive ints, and while they may not be contiguous they shouldn't be too huge.
@@ -27,12 +27,12 @@ NHASHTABLES := 17;
2727

2828
newSplitHashTableDict := function(hash1, hash2, npieces, magic)
2929
local r, tables, t, i;
30-
r := rec(npieces := npieces, hash1 := hash1, hash2 := hash2, magic := magic,
30+
r := rec(npieces := npieces, hash1 := hash1, hash2 := hash2, magic := magic,
3131
tables := []);
3232
for i in [1..npieces] do
33-
r.tables[i] := rec(next := 1 + (i-1)*magic, top := i*magic, table :=
33+
r.tables[i] := rec(next := 1 + (i-1)*magic, top := i*magic, table :=
3434
SparseHashTable(hash2));
35-
35+
3636
od;
3737
for t in r.tables do
3838
ShareObj(t);
@@ -42,7 +42,7 @@ newSplitHashTableDict := function(hash1, hash2, npieces, magic)
4242
end;
4343

4444
#
45-
# Two approaches to managing the hash tables.
45+
# Two approaches to managing the hash tables.
4646
# optimum might well be to switch from 1 to 2
4747
# once the rediscovery rate gets high enough.
4848
#
@@ -78,7 +78,7 @@ SHTaddOrLookup2 := function(dict, obj)
7878
if ht = fail then
7979
atomic readwrite t do
8080
ht := GetHashEntry(t.table,obj);
81-
if ht = fail then
81+
if ht = fail then
8282
ht := t.next;
8383
t.next := t.next+1;
8484
if t.next > t.top then
@@ -89,7 +89,7 @@ SHTaddOrLookup2 := function(dict, obj)
8989
return -ht;
9090
fi;
9191
od;
92-
92+
9393
fi;
9494
return ht;
9595
end;
@@ -105,7 +105,7 @@ task := function( points, parentids, gennos, gens, action, dict, addOrLookup, re
105105
MakeImmutable(parents);
106106
MakeImmutable(ngennos);
107107
ATOMIC_ADDITION(l,1,1);
108-
ATOMIC_ADDITION(l,2,1);
108+
ATOMIC_ADDITION(l,2,1);
109109
RunAsyncTask(task, npts, parents, ngennos, gens, action, dict, addOrLookup, record, l, sem);
110110
end;
111111
npts := [];
@@ -130,8 +130,8 @@ task := function( points, parentids, gennos, gens, action, dict, addOrLookup, re
130130
od;
131131
if Length(parents) > 0 then
132132
emit();
133-
fi;
134-
133+
fi;
134+
135135
ATOMIC_ADDITION(l,1,-1);
136136
if l[1] = 0 then
137137
SignalSemaphore(sem);
@@ -154,7 +154,7 @@ HTaddOrLookup := function(ht, obj)
154154
return res;
155155
end;
156156

157-
157+
158158

159159
seqorb := function( seeds, gens, action, dict, addOrLookup, record)
160160
local queue, qids, i, ngens, pt, npt, newid,j ;
@@ -177,30 +177,34 @@ seqorb := function( seeds, gens, action, dict, addOrLookup, record)
177177
od;
178178
end;
179179

180-
181-
182-
180+
181+
182+
183183
parorb := function( seeds, gens, action, dict, addOrLookup, record)
184184
local l, sem, fakes;
185185
l := FixedAtomicList([0,0]);
186186
sem := CreateSemaphore(0);
187187
seeds := Immutable(seeds);
188188
fakes := `List(seeds, s->fail);
189189
ATOMIC_ADDITION(l, 1, 1);
190-
ATOMIC_ADDITION(l,2,1);
190+
ATOMIC_ADDITION(l,2,1);
191191
RunAsyncTask(task, seeds, fakes, fakes, gens, action, dict, addOrLookup, record, l, sem);
192192
# while true do Print(l[1]," ",l[2],"\n");
193193
# od;
194194
if l[1] > 0 then
195195
WaitSemaphore(sem);
196196
fi;
197-
197+
198198
return l[2];
199199
end;
200200

201-
hash := function(s)
201+
hash := function(s)
202202
local sp;
203-
sp := AsPlist(s);
203+
if IsPlistRep(x) then
204+
sp := s;
205+
else
206+
sp := PlainListCopy(s);
207+
fi;
204208
return HashKeyBag(sp, 0,0,SIZE_OBJ(sp));
205209
end;
206210

@@ -252,44 +256,44 @@ actionViaParOrb := function(seeds, gens, action, hash)
252256
return realacts;
253257
end;
254258

255-
259+
256260

257261
m24trial := function()
258262
local d, gens, orb;
259263
orb := AtomicList([]);
260264
d := newSplitHashTableDict(x->x, x->x, NHASHTABLES, 100);
261265
gens := GeneratorsOfGroup(MathieuGroup(24));
262-
parorb([1], gens, OnPoints, d, SHTaddOrLookup, function(a,b,c)
266+
parorb([1], gens, OnPoints, d, SHTaddOrLookup, function(a,b,c)
263267
end);
264268
return keysOfSHT(d);
265-
269+
266270
end;
267271

268272
m24trialn := function(n)
269273
local d, gens;
270274
d := newSplitHashTableDict(hash, hash, NHASHTABLES, 100);
271275
gens := GeneratorsOfGroup(MathieuGroup(24));
272-
parorb([`[1..n]], gens, OnSets, d, SHTaddOrLookup, function(a,b,c)
276+
parorb([`[1..n]], gens, OnSets, d, SHTaddOrLookup, function(a,b,c)
273277
end);
274278
return keysOfSHT(d);
275-
279+
276280
end;
277281

278282
m24seqtrialn := function(n)
279283
local d, gens, orb;
280284
orb := [];
281-
d := SeqDict(hash);
285+
d := SeqDict(hash);
282286
gens := GeneratorsOfGroup(MathieuGroup(24));
283-
seqorb([AsPlist([1..n])], gens, OnSets, d, HTaddOrLookup, function(a,b,c)
287+
seqorb([PlainListCopy([1..n])], gens, OnSets, d, HTaddOrLookup, function(a,b,c)
284288
end);
285289
return Filtered(d.table!.KeyArray, x->x<>fail);
286290
end;
287291

288292
m24act := function(n)
289293
local gens;
290294
gens := GeneratorsOfGroup(MathieuGroup(24));
291-
return actionViaParOrb([`AsPlist([1..n])], gens, OnSets, hash);
295+
return actionViaParOrb([`PlainListCopy([1..n])], gens, OnSets, hash);
292296
end;
293297

294-
295-
298+
299+

hpcgap/lib/vec8bit.gi

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1096,11 +1096,11 @@ InstallMethodWithRandomSource( Randomize,
10961096
InstallMethod( Unpack, "for an 8bit matrix",
10971097
[Is8BitMatrixRep],
10981098
function( m )
1099-
return List(m,AsPlist);
1099+
return List(m, PlainListCopy);
11001100
end );
11011101
InstallMethod( Unpack, "for an 8bit vector",
11021102
[Is8BitVectorRep],
1103-
AsPlist );
1103+
PlainListCopy );
11041104

11051105
InstallOtherMethod( KroneckerProduct, "for two 8bit matrices", # priority to kernel code, if matrices have same field
11061106
[Is8BitMatrixRep and IsMatrix, Is8BitMatrixRep and IsMatrix], 1,

hpcgap/lib/vecmat.gi

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2538,11 +2538,11 @@ InstallMethodWithRandomSource( Randomize,
25382538
InstallMethod( Unpack, "for a gf2 matrix",
25392539
[IsGF2MatrixRep],
25402540
function( m )
2541-
return List(m,AsPlist);
2541+
return List(m, PlainListCopy);
25422542
end );
25432543
InstallMethod( Unpack, "for a gf2 vector",
25442544
[IsGF2VectorRep],
2545-
AsPlist );
2545+
PlainListCopy );
25462546

25472547
InstallOtherMethod( KroneckerProduct, "for two gf2 matrices",
25482548
[IsGF2MatrixRep and IsMatrix, IsGF2MatrixRep and IsMatrix],

lib/coll.gi

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -315,10 +315,10 @@ InstallMethod( AsSSortedList,
315315
[ IsCollection ],
316316
coll -> ConstantTimeAccessList( EnumeratorSorted( coll ) ) );
317317

318-
InstallOtherMethod( AsSSortedList,
318+
InstallMethod( AsSSortedList,
319319
"for a collection that is a constant time access list",
320320
[ IsCollection and IsConstantTimeAccessList ],
321-
l->AsSSortedListList(AsPlist(l)) );
321+
l->AsSSortedListList(PlainListCopy(l)) );
322322

323323
#############################################################################
324324
##

lib/dicthf.gi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ function(m, v)
162162
return function(x)
163163
Assert(1, IsPositionsList(x));
164164
if not IsPlistRep(x) then
165-
x := AsPlist(x);
165+
x := PlainListCopy(x);
166166
fi;
167167
return HashKeyBag(x, 1, 0, Length(x) * GAPInfo.BytesPerVariable);
168168
end;

lib/list.gd

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -362,23 +362,6 @@ DeclareAttribute( "ConstantTimeAccessList", IsList );
362362
DeclareSynonym( "AsSSortedListList", AS_LIST_SORTED_LIST );
363363

364364

365-
#############################################################################
366-
##
367-
#A AsPlist( <l> )
368-
##
369-
## <ManSection>
370-
## <Attr Name="AsPlist" Arg='l'/>
371-
##
372-
## <Description>
373-
## <Ref Attr="AsPlist"/> returns a list in the representation
374-
## <Ref Filt="IsPlistRep"/> that is equal to the list <A>l</A>.
375-
## It is used before calling kernel functions to sort plists.
376-
## </Description>
377-
## </ManSection>
378-
##
379-
DeclareOperation( "AsPlist", [IsListOrCollection] );
380-
381-
382365
#############################################################################
383366
##
384367
#C IsDenseList( <obj> )

lib/list.gi

Lines changed: 3 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -630,28 +630,6 @@ InstallOtherMethod( AsList,
630630
Immutable );
631631

632632

633-
#############################################################################
634-
##
635-
#M AsPlist( <list> )
636-
##
637-
InstallOtherMethod( AsPlist,
638-
"for a plist",
639-
[IsList and IsPlistRep],
640-
x -> x );
641-
642-
InstallOtherMethod( AsPlist,
643-
"for a list",
644-
[ IsList ],
645-
function(l)
646-
l:=AsList(l);
647-
if not IsPlistRep(l) then
648-
l:=PlainListCopy(l); # explicit copy for objects that claim to
649-
# be constant time access but not plists.
650-
fi;
651-
return l;
652-
end );
653-
654-
655633
#############################################################################
656634
##
657635
#M AsSSortedList( <list> )
@@ -672,7 +650,7 @@ InstallOtherMethod(AsSSortedList,
672650
InstallOtherMethod(AsSSortedList,
673651
"for a list",
674652
[ IsList ],
675-
l -> AsSSortedListList( AsPlist( l ) ) );
653+
l -> AsSSortedListList( PlainListCopy( l ) ) );
676654

677655
InstallMethod( AsSSortedList,
678656
"for a strictly sorted list",
@@ -710,7 +688,7 @@ function(l)
710688
if IsSSortedList(l) then
711689
return l;
712690
fi;
713-
return AsSSortedListList(AsPlist(l));
691+
return AsSSortedListList(PlainListCopy(l));
714692
end);
715693

716694

@@ -724,7 +702,7 @@ InstallMethod( SSortedList, "for a plist",
724702

725703
InstallMethod( SSortedList, "for a list",
726704
[ IsList ],
727-
l->SSortedListList(AsPlist(l)) );
705+
l->SSortedListList(PlainListCopy(l)) );
728706

729707

730708
#############################################################################

lib/vec8bit.gi

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1051,11 +1051,11 @@ InstallMethodWithRandomSource( Randomize,
10511051
InstallMethod( Unpack, "for an 8bit matrix",
10521052
[Is8BitMatrixRep],
10531053
function( m )
1054-
return List(m,AsPlist);
1054+
return List(m, PlainListCopy);
10551055
end );
10561056
InstallMethod( Unpack, "for an 8bit vector",
10571057
[Is8BitVectorRep],
1058-
AsPlist );
1058+
PlainListCopy );
10591059

10601060
InstallOtherMethod( KroneckerProduct, "for two 8bit matrices", # priority to kernel code, if matrices have same field
10611061
[Is8BitMatrixRep and IsMatrix, Is8BitMatrixRep and IsMatrix], 1,

lib/vecmat.gi

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2536,11 +2536,11 @@ InstallMethodWithRandomSource( Randomize,
25362536
InstallMethod( Unpack, "for a gf2 matrix",
25372537
[IsGF2MatrixRep],
25382538
function( m )
2539-
return List(m,AsPlist);
2539+
return List(m, PlainListCopy);
25402540
end );
25412541
InstallMethod( Unpack, "for a gf2 vector",
25422542
[IsGF2VectorRep],
2543-
AsPlist );
2543+
PlainListCopy );
25442544

25452545
InstallOtherMethod( KroneckerProduct, "for two gf2 matrices",
25462546
[IsGF2MatrixRep and IsMatrix, IsGF2MatrixRep and IsMatrix],

tst/testinstall/range.tst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@ gap> SetX(ranges, ranges,
273273
> local c;
274274
> c:=ShallowCopy(a);
275275
> IntersectSet(c,b);
276-
> return c = Intersection(AsPlist(a),AsPlist(b));
276+
> return c = Intersection(PlainListCopy(a),PlainListCopy(b));
277277
> end);
278278
[ true ]
279279

0 commit comments

Comments
 (0)