ds: formatting tweaks
This commit is contained in:
@@ -36,9 +36,16 @@ struct fx_dict_iterator_p {
|
||||
/*** MISC FUNCTIONS ***********************************************************/
|
||||
|
||||
static FX_BST_DEFINE_SIMPLE_GET(
|
||||
struct fx_dict_bucket, uint64_t, bk_node, bk_hash, get_bucket);
|
||||
struct fx_dict_bucket,
|
||||
uint64_t,
|
||||
bk_node,
|
||||
bk_hash,
|
||||
get_bucket);
|
||||
static FX_BST_DEFINE_SIMPLE_INSERT(
|
||||
struct fx_dict_bucket, bk_node, bk_hash, put_bucket);
|
||||
struct fx_dict_bucket,
|
||||
bk_node,
|
||||
bk_hash,
|
||||
put_bucket);
|
||||
|
||||
uint64_t fx_cstr_hash(const char *s)
|
||||
{
|
||||
@@ -79,7 +86,10 @@ static struct fx_dict_bucket_item *create_bucket_item(void)
|
||||
return item;
|
||||
}
|
||||
|
||||
static fx_status dict_put(struct fx_dict_p *dict, const char *key, fx_object *value)
|
||||
static fx_status dict_put(
|
||||
struct fx_dict_p *dict,
|
||||
const char *key,
|
||||
fx_object *value)
|
||||
{
|
||||
uint64_t hash = fx_cstr_hash(key);
|
||||
struct fx_dict_bucket *bucket = get_bucket(&dict->d_buckets, hash);
|
||||
@@ -107,7 +117,9 @@ static fx_status dict_put(struct fx_dict_p *dict, const char *key, fx_object *va
|
||||
}
|
||||
|
||||
static fx_status dict_put_sk(
|
||||
struct fx_dict_p *dict, const fx_string *key, fx_object *value)
|
||||
struct fx_dict_p *dict,
|
||||
const fx_string *key,
|
||||
fx_object *value)
|
||||
{
|
||||
uint64_t hash = fx_string_hash(key);
|
||||
struct fx_dict_bucket *bucket = get_bucket(&dict->d_buckets, hash);
|
||||
@@ -250,8 +262,10 @@ static bool dict_is_empty(const struct fx_dict_p *dict)
|
||||
}
|
||||
|
||||
static bool get_next_node(
|
||||
struct fx_bst_node *cur_node, struct fx_queue_entry *cur_entry,
|
||||
struct fx_bst_node **out_next_node, struct fx_queue_entry **out_next_entry)
|
||||
struct fx_bst_node *cur_node,
|
||||
struct fx_queue_entry *cur_entry,
|
||||
struct fx_bst_node **out_next_node,
|
||||
struct fx_queue_entry **out_next_entry)
|
||||
{
|
||||
struct fx_dict_bucket *cur_bucket
|
||||
= fx_unbox(struct fx_dict_bucket, cur_node, bk_node);
|
||||
@@ -298,7 +312,8 @@ static bool get_next_node(
|
||||
}
|
||||
|
||||
static fx_status delete_item(
|
||||
struct fx_dict_p *dict, struct fx_dict_bucket *bucket,
|
||||
struct fx_dict_p *dict,
|
||||
struct fx_dict_bucket *bucket,
|
||||
struct fx_dict_bucket_item *item)
|
||||
{
|
||||
fx_queue_delete(&bucket->bk_items, &item->bi_entry);
|
||||
@@ -401,11 +416,15 @@ static void dict_fini(fx_object *obj, void *priv)
|
||||
struct fx_bst_node *next_node = fx_bst_next(node);
|
||||
fx_bst_delete(&dict->d_buckets, node);
|
||||
|
||||
struct fx_queue_entry *entry = fx_queue_first(&bucket->bk_items);
|
||||
struct fx_queue_entry *entry
|
||||
= fx_queue_first(&bucket->bk_items);
|
||||
while (entry) {
|
||||
struct fx_dict_bucket_item *item = fx_unbox(
|
||||
struct fx_dict_bucket_item, entry, bi_entry);
|
||||
struct fx_queue_entry *next_entry = fx_queue_next(entry);
|
||||
struct fx_dict_bucket_item,
|
||||
entry,
|
||||
bi_entry);
|
||||
struct fx_queue_entry *next_entry
|
||||
= fx_queue_next(entry);
|
||||
fx_queue_delete(&bucket->bk_items, entry);
|
||||
|
||||
free(item->bi_str);
|
||||
@@ -440,16 +459,20 @@ static void dict_to_string(const fx_object *obj, fx_stream *out)
|
||||
struct fx_dict_bucket *bucket
|
||||
= fx_unbox(struct fx_dict_bucket, node, bk_node);
|
||||
|
||||
struct fx_queue_entry *entry = fx_queue_first(&bucket->bk_items);
|
||||
struct fx_queue_entry *entry
|
||||
= fx_queue_first(&bucket->bk_items);
|
||||
while (entry) {
|
||||
struct fx_dict_bucket_item *item = fx_unbox(
|
||||
struct fx_dict_bucket_item, entry, bi_entry);
|
||||
struct fx_dict_bucket_item,
|
||||
entry,
|
||||
bi_entry);
|
||||
|
||||
fx_object_to_string(item->bi_str, out);
|
||||
fx_stream_write_cstr(out, ": ", NULL);
|
||||
|
||||
bool is_string = fx_object_is_type(
|
||||
item->bi_value, FX_TYPE_STRING);
|
||||
item->bi_value,
|
||||
FX_TYPE_STRING);
|
||||
|
||||
if (is_string) {
|
||||
fx_stream_write_char(out, '"');
|
||||
|
||||
Reference in New Issue
Block a user