nostrdb

an unfairly fast embedded nostr database backed by lmdb
git clone git://jb55.com/nostrdb
Log | Files | Refs | Submodules | README | LICENSE

commit f323474545e107248f0e461ec6f1b3d65c1687a6
parent f6cb3f6ef79fc08af8e8b596b11de59e3a1d0bfa
Author: William Casarin <jb55@jb55.com>
Date:   Thu,  4 Jan 2024 08:28:02 -0800

ocd: small cleanup

Diffstat:
Msrc/nostrdb.c | 12++++++------
1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/src/nostrdb.c b/src/nostrdb.c @@ -741,7 +741,6 @@ int ndb_filter_add_id_element(struct ndb_filter *filter, const unsigned char *id return ndb_filter_add_element(filter, el); } -// TODO: build a hashtable so this is O(1) static int ndb_generic_filter_matches(struct ndb_filter_elements *els, struct ndb_note *note) { @@ -840,6 +839,7 @@ static int compare_kinds(const void *pa, const void *pb) int ndb_filter_matches(struct ndb_filter *filter, struct ndb_note *note) { int i, j; + unsigned char *id; struct ndb_filter_elements *els; for (i = 0; i < filter->num_elements; i++) { @@ -853,17 +853,17 @@ int ndb_filter_matches(struct ndb_filter *filter, struct ndb_note *note) } break; case NDB_FILTER_IDS: - unsigned char *id = note->id; + id = note->id; if (bsearch(&id, &els->elements[0], els->count, sizeof(els->elements[0].id), compare_ids)) { - goto cont; + continue; } break; case NDB_FILTER_AUTHORS: - unsigned char *pubkey = note->pubkey; - if (bsearch(&pubkey, &els->elements[0], els->count, + id = note->pubkey; + if (bsearch(&id, &els->elements[0], els->count, sizeof(els->elements[0].id), compare_ids)) { - goto cont; + continue; } break; case NDB_FILTER_GENERIC: