diff options
author | glass <glass@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2013-11-27 16:07:10 +0000 |
---|---|---|
committer | glass <glass@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2013-11-27 16:07:10 +0000 |
commit | b426e1b1fafdab688c646cef8245fa72403d37bb (patch) | |
tree | f2f8f4a5cdc96af495ee1867c3aaef0f0f2d244a /include/ruby/st.h | |
parent | 884682755a471545145eb4a4598d06d9bc4dd2d6 (diff) | |
download | ruby-b426e1b1fafdab688c646cef8245fa72403d37bb.tar.gz |
* st.c (st_keys): define st_keys(). it writes each key to buffer.
* hash.c (rb_hash_keys): use st_keys() for performance improvement
if st_data_t and VALUE are compatible.
* st.h: define macro ST_DATA_COMPATIBLE_P() to predicate whether
st_data_t and passed type are compatible.
* configure.in: check existence of builtin function to use in
ST_DATA_COMPATIBLE_P().
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43885 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'include/ruby/st.h')
-rw-r--r-- | include/ruby/st.h | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/include/ruby/st.h b/include/ruby/st.h index e71301b519..fa6190dcd6 100644 --- a/include/ruby/st.h +++ b/include/ruby/st.h @@ -59,6 +59,13 @@ struct st_hash_type { #define ST_INDEX_BITS (sizeof(st_index_t) * CHAR_BIT) +#if defined(HAVE_BUILTIN___BUILTIN_CHOOSE_EXPR) && defined(HAVE_BUILTIN___BUILTIN_TYPES_COMPATIBLE_P) +# define ST_DATA_COMPATIBLE_P(type) \ + __builtin_choose_expr(__builtin_types_compatible_p(type, st_data_t), 1, 0) +#else +# define ST_DATA_COMPATIBLE_P(type) 0 +#endif + struct st_table { const struct st_hash_type *type; st_index_t num_bins; @@ -112,6 +119,7 @@ int st_update(st_table *table, st_data_t key, st_update_callback_func *func, st_ int st_foreach(st_table *, int (*)(ANYARGS), st_data_t); int st_foreach_check(st_table *, int (*)(ANYARGS), st_data_t, st_data_t); int st_reverse_foreach(st_table *, int (*)(ANYARGS), st_data_t); +st_index_t st_keys(st_table *table, st_data_t *keys, st_index_t size); void st_add_direct(st_table *, st_data_t, st_data_t); void st_free_table(st_table *); void st_cleanup_safe(st_table *, st_data_t); |