mirror of
https://github.com/aljazceru/notedeck.git
synced 2025-12-18 00:54:21 +01:00
perf: improve filter generation performance
for some reason the filter here was taking ~6ms to create... Signed-off-by: kernelkind <kernelkind@gmail.com>
This commit is contained in:
@@ -626,11 +626,15 @@ impl TimelineKind {
|
||||
pub fn notifications_filter(pk: &Pubkey) -> Filter {
|
||||
Filter::new()
|
||||
.pubkeys([pk.bytes()])
|
||||
.kinds([1, 7, 6])
|
||||
.kinds(notification_kinds())
|
||||
.limit(default_limit())
|
||||
.build()
|
||||
}
|
||||
|
||||
pub fn notification_kinds() -> [u64; 3] {
|
||||
[1, 7, 6]
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct TitleNeedsDb<'a> {
|
||||
kind: &'a TimelineKind,
|
||||
|
||||
@@ -25,8 +25,12 @@ pub fn unseen_notification(
|
||||
profiling::scope!("NotesFreshness::update closure");
|
||||
let filter = {
|
||||
profiling::scope!("NotesFreshness::update filter instantiation");
|
||||
crate::timeline::kind::notifications_filter(¤t_pk)
|
||||
.since_mut(timestamp_last_viewed)
|
||||
enostr::Filter::new_with_capacity(1)
|
||||
.pubkeys([current_pk.bytes()])
|
||||
.kinds(crate::timeline::kind::notification_kinds())
|
||||
.limit(1)
|
||||
.since(timestamp_last_viewed)
|
||||
.build()
|
||||
};
|
||||
let txn = Transaction::new(ndb).expect("txn");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user