caio.co/de/caca

Better name for TopK peek() alt

It wasn't DeMorgan, it was terrible naming and missing server-side
setup. Then the logic trauma kicked in lel

Should add tests one day
Id
c417c2e6fa0b09690c29bdc1ac3b46c7619208f4
Author
Caio
Commit time
2024-03-13T14:08:31+01:00

Modified caca/src/repo/feed.rs

@@ -131,7 +131,7
Self { q, k }
}

- pub(crate) fn min(&self) -> Option<&T> {
+ pub(crate) fn last(&self) -> Option<&T> {
self.q.peek().map(|Reverse(i)| i)
}

Modified caca/src/repo/mod.rs

@@ -324,7 +324,7
// when at capacity, can't add anything if `rev`s tip
// is older than the oldest entry in the feed
if feed.len() == limit
- && feed.min().expect("feed is at capacity").time() < rev.commit.author.time
+ && feed.last().expect("feed is at capacity").time() >= rev.commit.author.time
{
return Ok(false);
}