diff options
author | ko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2018-10-30 22:11:51 +0000 |
---|---|---|
committer | ko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2018-10-30 22:11:51 +0000 |
commit | 8f675cdd00e2c5b5a0f143f5e508dbbafdb20ccd (patch) | |
tree | b4fcdae0f66e8ff51964c946e61ae00aee797fef /class.c | |
parent | ca83ed8db65409d04a77a1e5618291fa5cac6819 (diff) |
support theap for T_HASH. [Feature #14989]
* hash.c, internal.h: support theap for small Hash.
Introduce RHASH_ARRAY (li_table) besides st_table and small Hash
(<=8 entries) are managed by an array data structure.
This array data can be managed by theap.
If st_table is needed, then converting array data to st_table data.
For st_table using code, we prepare "stlike" APIs which accepts hash value
and are very similar to st_ APIs.
This work is based on the GSoC achievement
by tacinight <[email protected]> and refined by ko1.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65454 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'class.c')
-rw-r--r-- | class.c | 9 |
1 files changed, 4 insertions, 5 deletions
@@ -1804,11 +1804,10 @@ NORETURN(static void unknown_keyword_error(VALUE hash, const ID *table, int keyw static void unknown_keyword_error(VALUE hash, const ID *table, int keywords) { - st_table *tbl = rb_hash_tbl_raw(hash); int i; for (i = 0; i < keywords; i++) { st_data_t key = ID2SYM(table[i]); - st_delete(tbl, &key, NULL); + rb_hash_stlike_delete(hash, &key, NULL); } rb_keyword_error("unknown", rb_hash_keys(hash)); } @@ -1855,7 +1854,7 @@ rb_extract_keywords(VALUE *orighash) *orighash = 0; return hash; } - st_foreach(rb_hash_tbl_raw(hash), separate_symbol, (st_data_t)&arg); + rb_hash_foreach(hash, separate_symbol, (st_data_t)&arg); if (arg.kwdhash) { if (arg.nonsymkey != Qundef) { rb_raise(rb_eArgError, "non-symbol key in keyword arguments: %+"PRIsVALUE, @@ -1876,8 +1875,8 @@ rb_get_kwargs(VALUE keyword_hash, const ID *table, int required, int optional, V #define extract_kwarg(keyword, val) \ (key = (st_data_t)(keyword), values ? \ - st_delete(rb_hash_tbl_raw(keyword_hash), &key, (val)) : \ - st_lookup(rb_hash_tbl_raw(keyword_hash), key, (val))) + rb_hash_stlike_delete(keyword_hash, &key, (val)) : \ + rb_hash_stlike_lookup(keyword_hash, key, (val))) if (NIL_P(keyword_hash)) keyword_hash = 0; |