@@ -172,8 +172,8 @@ Object lruCacheNew(VirtualFrame frame, Object type,
172
172
173
173
LruCacheObject obj = factory ().createLruCacheObject (type );
174
174
175
- obj .prev = obj ;
176
- obj .next = obj ;
175
+ obj .root . prev = obj . root ;
176
+ obj .root . next = obj . root ;
177
177
obj .wrapper = wrapper ;
178
178
obj .typed = typed ;
179
179
// obj.cache = new ObjectHashMap();
@@ -184,8 +184,6 @@ Object lruCacheNew(VirtualFrame frame, Object type,
184
184
185
185
obj .kwdMark = getKwdMark (readAttr );
186
186
187
- // obj.lru_list_elem_type = state.lru_list_elem_type;
188
-
189
187
obj .cacheInfoType = cache_info_type ;
190
188
// obj.dict = null;
191
189
// obj.weakreflist = null;
@@ -370,7 +368,7 @@ static void lru_cache_prepend_link(LruCacheObject self, LruListElemObject link)
370
368
371
369
// lru_cache_append_link
372
370
static void lruCacheAppendLink (LruCacheObject self , LruListElemObject link ) {
373
- LruListElemObject root = self ;
371
+ LruListElemObject root = self . root ;
374
372
LruListElemObject last = root .prev ;
375
373
last .next = root .prev = link ;
376
374
link .prev = last ;
@@ -434,10 +432,6 @@ Object boundedLruCacheWrapper(VirtualFrame frame, LruCacheObject self, Object[]
434
432
self .hits ++;
435
433
return link .result ;
436
434
}
437
- // mq: this might be needed if self.cache is a dict
438
- // if (PyErr_Occurred()) {
439
- // return NULL;
440
- // }
441
435
self .misses ++;
442
436
Object result = callNode .execute (frame , self .func , args , kwds );
443
437
Object testresult = getItem .get (frame , self .cache , key , hash );
@@ -449,23 +443,15 @@ Object boundedLruCacheWrapper(VirtualFrame frame, LruCacheObject self, Object[]
449
443
*/
450
444
return result ;
451
445
}
452
- // mq: this will only occur if the cache is a dict.
453
- // if (PyErr_Occurred()) {
454
- // /* This is an unusual case since this same lookup
455
- // did not previously trigger an error during lookup.
456
- // Treat it the same as an error in user function
457
- // and return with the error set. */
458
- // return NULL;
459
- // }
460
446
/*
461
447
* This is the normal case. The new key wasn't found before user function call and it is
462
448
* still not there. So we proceed normally and update the cache with the new result.
463
449
*/
464
450
465
451
assert (self .maxsize > 0 );
466
- if (self .cache .size () < self .maxsize || self .next == self ) {
452
+ if (self .cache .size () < self .maxsize || self .root . next == self . root ) {
467
453
/* Cache is not full, so put the result in a new link */
468
- link = factory (). createLruListElemObject ();
454
+ link = new LruListElemObject ();
469
455
470
456
link .hash = hash ;
471
457
link .key = key ;
@@ -494,7 +480,7 @@ Object boundedLruCacheWrapper(VirtualFrame frame, LruCacheObject self, Object[]
494
480
495
481
/* Extract the oldest item. */
496
482
// assert (self.next != self);
497
- link = self .next ;
483
+ link = self .root . next ;
498
484
lruCacheExtractLink (link );
499
485
/*
500
486
* Remove it from the cache. The cache dict holds one reference to the link. We created
@@ -544,7 +530,7 @@ public abstract static class ClearNode extends PythonUnaryBuiltinNode {
544
530
545
531
// lru_cache_unlink_list
546
532
static LruListElemObject lruCacheUnlinkList (LruCacheObject self ) {
547
- LruListElemObject root = self ;
533
+ LruListElemObject root = self . root ;
548
534
LruListElemObject link = root .next ;
549
535
if (link == root ) {
550
536
return null ;
0 commit comments