commit 267a9ac54bb7f38459ec7c94b70fdf01079f4fa7
parent 8b03ed61754e94bf681f5c6b0b6c6c9863999367
Author: William Casarin <jb55@jb55.com>
Date: Thu, 4 Jan 2024 08:28:02 -0800
nostrdb/ocd: small cleanup
Signed-off-by: William Casarin <jb55@jb55.com>
Diffstat:
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git 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: