Skip to content

Commit 0262ac1

Browse files
committed
chore: minor polishing
1 parent 9996698 commit 0262ac1

1 file changed

Lines changed: 2 additions & 8 deletions

File tree

pkg/eviction/arc.go

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -320,10 +320,7 @@ func (a *ARC) updateIfResident(key string, value any) bool {
320320
// handleGhostHit processes B1/B2 hits and moves the key to T2 while adapting p.
321321
func (a *ARC) handleGhostHit(key string, value any) bool {
322322
if ghost, ok := a.b1Idx[key]; ok {
323-
increment := a.b2.len / arcIntMax(1, a.b1.len)
324-
if increment < 1 {
325-
increment = 1
326-
}
323+
increment := max(a.b2.len/arcIntMax(1, a.b1.len), 1)
327324

328325
a.p += increment
329326
if a.p > a.capacity {
@@ -344,10 +341,7 @@ func (a *ARC) handleGhostHit(key string, value any) bool {
344341
}
345342

346343
if ghost, ok := a.b2Idx[key]; ok {
347-
decrement := a.b1.len / arcIntMax(1, a.b2.len)
348-
if decrement < 1 {
349-
decrement = 1
350-
}
344+
decrement := max(a.b1.len/arcIntMax(1, a.b2.len), 1)
351345

352346
a.p -= decrement
353347
if a.p < 0 {

0 commit comments

Comments
 (0)