Skip to content

Commit 30f03bc

Browse files
authored
Replace unnecessary calls to MakeReadWriteGlobal (#20)
1 parent cfc71c7 commit 30f03bc

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

lib/general.gi

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -553,17 +553,16 @@ InstallGlobalFunction( PutIntoCache,
553553
local cache, pos, i;
554554

555555
cache := ValueGlobal(name);
556-
MakeReadWriteGlobal(name);
557556
pos := Position(List(cache,t->t[1]),key,1);
558557
if pos = fail then Add(cache,[key,0,value]);
559558
else cache[pos][2] := 0; fi;
560559
for i in [2..Length(cache)] do
561560
cache[i][2] := cache[i][2] + 1;
562561
od;
563562
Sort(cache,function(t1,t2) return t1[2]<t2[2]; end);
564-
if Length(cache) > cache[1][1]+1
565-
then cache := cache{[1..cache[1][1]+1]}; fi;
566-
MakeReadOnlyGlobal(name);
563+
while Length(cache) > cache[1][1]+1 do
564+
Remove(cache);
565+
od;
567566
end );
568567

569568
#############################################################################
@@ -579,12 +578,10 @@ InstallGlobalFunction( "FetchFromCache",
579578
cache := ValueGlobal(name);
580579
pos := Position(List(cache,t->t[1]),key,1);
581580
if IsInt(pos) then
582-
MakeReadWriteGlobal(name);
583581
cache[pos][2] := 0;
584582
for i in [2..Length(cache)] do
585583
cache[i][2] := cache[i][2] + 1;
586584
od;
587-
MakeReadOnlyGlobal(name);
588585
return cache[pos][3];
589586
fi;
590587
return fail;

0 commit comments

Comments
 (0)