mirror of
https://github.com/aljazceru/notedeck.git
synced 2025-12-18 17:14: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 {
|
pub fn notifications_filter(pk: &Pubkey) -> Filter {
|
||||||
Filter::new()
|
Filter::new()
|
||||||
.pubkeys([pk.bytes()])
|
.pubkeys([pk.bytes()])
|
||||||
.kinds([1, 7, 6])
|
.kinds(notification_kinds())
|
||||||
.limit(default_limit())
|
.limit(default_limit())
|
||||||
.build()
|
.build()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn notification_kinds() -> [u64; 3] {
|
||||||
|
[1, 7, 6]
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct TitleNeedsDb<'a> {
|
pub struct TitleNeedsDb<'a> {
|
||||||
kind: &'a TimelineKind,
|
kind: &'a TimelineKind,
|
||||||
|
|||||||
@@ -25,8 +25,12 @@ pub fn unseen_notification(
|
|||||||
profiling::scope!("NotesFreshness::update closure");
|
profiling::scope!("NotesFreshness::update closure");
|
||||||
let filter = {
|
let filter = {
|
||||||
profiling::scope!("NotesFreshness::update filter instantiation");
|
profiling::scope!("NotesFreshness::update filter instantiation");
|
||||||
crate::timeline::kind::notifications_filter(¤t_pk)
|
enostr::Filter::new_with_capacity(1)
|
||||||
.since_mut(timestamp_last_viewed)
|
.pubkeys([current_pk.bytes()])
|
||||||
|
.kinds(crate::timeline::kind::notification_kinds())
|
||||||
|
.limit(1)
|
||||||
|
.since(timestamp_last_viewed)
|
||||||
|
.build()
|
||||||
};
|
};
|
||||||
let txn = Transaction::new(ndb).expect("txn");
|
let txn = Transaction::new(ndb).expect("txn");
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user