File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -122,24 +122,10 @@ let styleCache;
122122
123123const kHexStyleCacheMax = 256 ;
124124
125- class HexStyleFIFOCache {
126- #cache = new SafeMap ( ) ;
127-
128- get ( key ) {
129- return this . #cache. get ( key ) ;
130- }
131-
132- set ( key , value ) {
133- if ( this . #cache. size >= kHexStyleCacheMax )
134- this . #cache. delete ( this . #cache. keys ( ) . next ( ) . value ) ;
135- this . #cache. set ( key , value ) ;
136- }
137- }
138-
139125let hexStyleCache ;
140126
141127function getHexStyleCache ( ) {
142- hexStyleCache ??= new HexStyleFIFOCache ( ) ;
128+ hexStyleCache ??= new SafeMap ( ) ;
143129 return hexStyleCache ;
144130}
145131
@@ -180,6 +166,8 @@ function getHexStyle(hex) {
180166 openSeq : kEscape + rgbToAnsi24Bit ( r , g , b ) + kEscapeEnd ,
181167 closeSeq : kHexCloseSeq ,
182168 } ;
169+ if ( cache . size >= kHexStyleCacheMax )
170+ cache . delete ( cache . keys ( ) . next ( ) . value ) ;
183171 cache . set ( hex , style ) ;
184172 return style ;
185173}
You can’t perform that action at this time.
0 commit comments