提交 21d2c92f 编写于 作者: B Behdad Esfahbod

Move code around

上级 448ea9bf
...@@ -106,20 +106,20 @@ typedef struct { ...@@ -106,20 +106,20 @@ typedef struct {
/* XXX make this thread-safe, somehow! */ /* XXX make this thread-safe, somehow! */
struct hb_user_data_t { struct hb_user_data_array_t {
struct hb_user_data_item_t {
hb_user_data_key_t *key; hb_user_data_key_t *key;
void *data; void *data;
hb_destroy_func_t destroy; hb_destroy_func_t destroy;
inline bool operator == (hb_user_data_key_t *other_key) const { return key == other_key; } inline bool operator == (hb_user_data_key_t *other_key) const { return key == other_key; }
inline bool operator == (hb_user_data_t &other) const { return key == other.key; } inline bool operator == (hb_user_data_item_t &other) const { return key == other.key; }
void finish (void) { if (destroy) destroy (data); } void finish (void) { if (destroy) destroy (data); }
}; };
struct hb_user_data_array_t {
hb_set_t<hb_user_data_t> items; hb_set_t<hb_user_data_item_t> items;
inline bool set (hb_user_data_key_t *key, inline bool set (hb_user_data_key_t *key,
void * data, void * data,
...@@ -131,13 +131,13 @@ struct hb_user_data_array_t { ...@@ -131,13 +131,13 @@ struct hb_user_data_array_t {
items.remove (key); items.remove (key);
return true; return true;
} }
hb_user_data_t user_data = {key, data, destroy}; hb_user_data_item_t item = {key, data, destroy};
return items.insert (user_data); return items.insert (item);
} }
inline void *get (hb_user_data_key_t *key) { inline void *get (hb_user_data_key_t *key) {
hb_user_data_t *user_data = items.get (key); hb_user_data_item_t *item = items.get (key);
return user_data ? user_data->data : NULL; return item ? item->data : NULL;
} }
void finish (void) { items.finish (); } void finish (void) { items.finish (); }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册