Skip to content

Commit

Permalink
PoC: replace hash tables by arrays
Browse files Browse the repository at this point in the history
This basically implements the functionality and the testbench
passes. We still need more tests and expect regressions.

see also rsyslog#35
  • Loading branch information
rgerhards committed Apr 11, 2016
1 parent 2b92882 commit 239e5a4
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 48 deletions.
47 changes: 0 additions & 47 deletions json_object.c
Original file line number Diff line number Diff line change
Expand Up @@ -466,32 +466,6 @@ void fjson_object_object_add_ex(struct fjson_object* jso,
done:
return;
}
#if 0
void fjson_object_object_add_ex(struct fjson_object* jso,
const char *const key,
struct fjson_object *const val,
const unsigned opts)
{
// We lookup the entry and replace the value, rather than just deleting
// and re-adding it, so the existing key remains valid.
fjson_object *existing_value = NULL;
struct lh_entry *existing_entry;
const unsigned long hash = lh_get_hash(jso->o.c_object, (void*)key);
existing_entry = (opts & FJSON_OBJECT_ADD_KEY_IS_NEW) ? NULL :
lh_table_lookup_entry_w_hash(jso->o.c_object, (void*)key, hash);
if (!existing_entry)
{
void *const k = (opts & FJSON_OBJECT_KEY_IS_CONSTANT) ?
(void*)key : strdup(key);
lh_table_insert_w_hash(jso->o.c_object, k, val, hash, opts);
return;
}
existing_value = (fjson_object *)existing_entry->v;
if (existing_value)
fjson_object_put(existing_value);
existing_entry->v = val;
}
#endif

void fjson_object_object_add(struct fjson_object *const __restrict__ jso,
const char *const key,
Expand Down Expand Up @@ -526,27 +500,6 @@ void fjson_object_object_add(struct fjson_object *const __restrict__ jso,
done:
return;
}
#if 0
void fjson_object_object_add(struct fjson_object* jso, const char *key,
struct fjson_object *val)
{
// We lookup the entry and replace the value, rather than just deleting
// and re-adding it, so the existing key remains valid.
fjson_object *existing_value = NULL;
struct lh_entry *existing_entry;
const unsigned long hash = lh_get_hash(jso->o.c_object, (void*)key);
existing_entry = lh_table_lookup_entry_w_hash(jso->o.c_object, (void*)key, hash);
if (!existing_entry)
{
lh_table_insert_w_hash(jso->o.c_object, strdup(key), val, hash, 0);
return;
}
existing_value = (fjson_object *)existing_entry->v;
if (existing_value)
fjson_object_put(existing_value);
existing_entry->v = val;
}
#endif


int fjson_object_object_length(struct fjson_object *jso)
Expand Down
1 change: 0 additions & 1 deletion json_object_private.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ struct fjson_object
fjson_bool c_boolean;
double c_double;
int64_t c_int64;
struct lh_table *c_object;
struct {
int nelem;
struct _fjson_child_pg pg;
Expand Down

0 comments on commit 239e5a4

Please sign in to comment.