nostrdb

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

commit 030f92e5f957780e144665bae20199ad70b9cf8c
parent 31823f9b544a4afb897b42b62d4653dd2975b493
Author: William Casarin <jb55@jb55.com>
Date:   Sat, 22 Jul 2023 11:06:17 -0700

json: try compact string before we unescape

Diffstat:
Mnostrdb.c | 7+++++--
1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/nostrdb.c b/nostrdb.c @@ -241,11 +241,13 @@ static int ndb_builder_make_json_str(struct ndb_builder *builder, { // let's not care about de-duping these. we should just unescape // in-place directly into the strings table. - - // TODO: we still want single-char packed strings const char *p, *end, *start; + // always try compact strings first + if (ndb_builder_try_compact_str(builder, str, len, pstr)) + return 1; + end = str + len; start = str; // Initialize start to the beginning of the string @@ -310,6 +312,7 @@ static int ndb_builder_make_json_str(struct ndb_builder *builder, return 0; } + // TODO: dedupe these!? return cursor_push_byte(&builder->strings, '\0'); }