Skip to content

Commit 725b3ca

Browse files
committed
move KHASH_DECLARE(ht..) to mruby/hash.h; close #3073
1 parent 7c82bfa commit 725b3ca

2 files changed

Lines changed: 10 additions & 6 deletions

File tree

include/mruby/hash.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
#define MRUBY_HASH_H
99

1010
#include "common.h"
11+
#include <mruby/khash.h>
1112

1213
/**
1314
* Hash class
@@ -59,6 +60,15 @@ MRB_API mrb_value mrb_hash_empty_p(mrb_state *mrb, mrb_value self);
5960
*/
6061
MRB_API mrb_value mrb_hash_clear(mrb_state *mrb, mrb_value hash);
6162

63+
/* declaration of struct kh_ht */
64+
/* be careful when you touch the internal */
65+
typedef struct {
66+
mrb_value v;
67+
mrb_int n;
68+
} mrb_hash_value;
69+
70+
KHASH_DECLARE(ht, mrb_value, mrb_hash_value, TRUE)
71+
6272
/* RHASH_TBL allocates st_table if not available. */
6373
#define RHASH(obj) ((struct RHash*)(mrb_ptr(obj)))
6474
#define RHASH_TBL(h) (RHASH(h)->ht)

src/hash.c

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -91,12 +91,6 @@ mrb_hash_ht_hash_equal(mrb_state *mrb, mrb_value a, mrb_value b)
9191
}
9292
}
9393

94-
typedef struct {
95-
mrb_value v;
96-
mrb_int n;
97-
} mrb_hash_value;
98-
99-
KHASH_DECLARE(ht, mrb_value, mrb_hash_value, TRUE)
10094
KHASH_DEFINE (ht, mrb_value, mrb_hash_value, TRUE, mrb_hash_ht_hash_func, mrb_hash_ht_hash_equal)
10195

10296
static void mrb_hash_modify(mrb_state *mrb, mrb_value hash);

0 commit comments

Comments
 (0)