From 267a9ac54bb7f38459ec7c94b70fdf01079f4fa7 Mon Sep 17 00:00:00 2001 From: William Casarin Date: Thu, 4 Jan 2024 08:28:02 -0800 Subject: [PATCH] nostrdb/ocd: small cleanup Signed-off-by: William Casarin --- nostrdb/src/nostrdb.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/nostrdb/src/nostrdb.c b/nostrdb/src/nostrdb.c index a42e854a..819a406d 100644 --- a/nostrdb/src/nostrdb.c +++ b/nostrdb/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: