@@ -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