Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
mruby
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Libraries
mruby
Commits
b1cc715b
Commit
b1cc715b
authored
Jul 30, 2012
by
Masaki Muranaka
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
MRB_INITIAL_HASH_SIZE : Make the initial hash size configurable.
parent
14410d13
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
11 deletions
+16
-11
include/mruby/khash.h
include/mruby/khash.h
+16
-11
No files found.
include/mruby/khash.h
View file @
b1cc715b
...
@@ -17,7 +17,10 @@ extern "C" {
...
@@ -17,7 +17,10 @@ extern "C" {
typedef
uint32_t
khint_t
;
typedef
uint32_t
khint_t
;
typedef
khint_t
khiter_t
;
typedef
khint_t
khiter_t
;
#define INITIAL_HASH_SIZE 32
#if !defined(MRB_INITIAL_HASH_SIZE)
# define MRB_INITIAL_HASH_SIZE 32
#endif
#define UPPER_BOUND(x) ((x)>>2|(x>>1))
#define UPPER_BOUND(x) ((x)>>2|(x>>1))
//extern uint8_t __m[];
//extern uint8_t __m[];
...
@@ -88,7 +91,7 @@ static const uint8_t __m[8] = {0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80};
...
@@ -88,7 +91,7 @@ static const uint8_t __m[8] = {0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80};
} \
} \
kh_##name##_t *kh_init_##name(mrb_state *mrb){ \
kh_##name##_t *kh_init_##name(mrb_state *mrb){ \
kh_##name##_t *h = (kh_##name##_t*)mrb_calloc(mrb, 1, sizeof(kh_##name##_t)); \
kh_##name##_t *h = (kh_##name##_t*)mrb_calloc(mrb, 1, sizeof(kh_##name##_t)); \
h->n_buckets =
INITIAL_HASH_SIZE;
\
h->n_buckets =
MRB_INITIAL_HASH_SIZE;
\
h->mrb = mrb; \
h->mrb = mrb; \
kh_alloc_##name(h); \
kh_alloc_##name(h); \
return h; \
return h; \
...
@@ -123,12 +126,14 @@ static const uint8_t __m[8] = {0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80};
...
@@ -123,12 +126,14 @@ static const uint8_t __m[8] = {0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80};
} \
} \
void kh_resize_##name(kh_##name##_t *h, khint_t new_n_buckets) \
void kh_resize_##name(kh_##name##_t *h, khint_t new_n_buckets) \
{ \
{ \
if( new_n_buckets<
INITIAL_HASH_SIZE ){
\
if( new_n_buckets<
MRB_INITIAL_HASH_SIZE ){
\
new_n_buckets =
INITIAL_HASH_SIZE;
\
new_n_buckets =
MRB_INITIAL_HASH_SIZE;
\
} else { \
} else { \
khint_t limit = new_n_buckets; \
khint_t limit = new_n_buckets; \
new_n_buckets = INITIAL_HASH_SIZE; \
new_n_buckets = MRB_INITIAL_HASH_SIZE; \
while( new_n_buckets < limit ) new_n_buckets *= 2; \
while( new_n_buckets < limit ) { \
new_n_buckets *= 2; \
} \
} \
} \
{ \
{ \
uint8_t *old_e_flags = h->e_flags; \
uint8_t *old_e_flags = h->e_flags; \
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment