summaryrefslogtreecommitdiffhomepage
path: root/src/hash.c
AgeCommit message (Collapse)Author
2020-06-20Add `mrb_get_arg1()` that retrieves single (and only) argument.Yukihiro "Matz" Matsumoto
`mrb_get_arg1()` raises `ArgumentError` if the method does not receive one argument. And replaces all `mrb_get_args(mrb, "o", &arg)` by the new function.
2020-06-05Add proper casts to silence VC warnings.Yukihiro "Matz" Matsumoto
2020-05-15Unify `eql?` receiver in `Hash` according to RubyKOBAYASHI Shuji
### Example ```ruby # example.rb class A def eql?(o) p self.class super end def hash 1 end end class B < A; end h = {A.new => 1} h[B.new] ``` #### Before this patch: ```console $ bin/mruby example.rb A ``` #### After this patch (same as Ruby) ```console $ bin/mruby example.rb B ```
2020-01-31Avoid implicit integer casting in `backtrace.c` and `hash.c`.Yukihiro "Matz" Matsumoto
2020-01-01Rename `mrb_num_args_error` to `mrb_argnum_error`; ref #4863Yukihiro "Matz" Matsumoto
2019-12-12Add `mrb_num_args_error()` for "wrong number of arguments" errorKOBAYASHI Shuji
To unify the style of messages.
2019-11-02Fix argument specs to `Hash`KOBAYASHI Shuji
2019-09-26Use type predicate macros instead of `mrb_type` if possibleKOBAYASHI Shuji
For efficiency with `MRB_WORD_BOXING` (implement type predicate macros for all `enum mrb_vtype`).
2019-09-14Add a macro `mrb_frozen_p` that points to `MRB_FROZEN_P`.Yukihiro "Matz" Matsumoto
2019-07-04It was too early to check `key` for `undef`; ref #4534Yukihiro "Matz" Matsumoto
2019-06-27Skip copying delete keys in a hash; fix #4534Yukihiro "Matz" Matsumoto
2019-06-22Refine `Hash#rehash` example [ci skip]KOBAYASHI Shuji
Previous example doesn't work because string key (frozen) can't be modified.
2019-04-14Fix memory leak for hash table index if occur out of memorydearblue
2019-04-09Extract frozen checking to functionKOBAYASHI Shuji
2019-02-11Should not copy keys&values when a hash table is empty; fix #4270Yukihiro "Matz" Matsumoto
2018-12-17Small refactoring of #4188Yukihiro "Matz" Matsumoto
2018-12-14Add `mrb_hash_size()` function.dearblue
2018-12-11Avoid using floating point number for HT_SEG_INCREASE_RATIO; ref #4182Yukihiro "Matz" Matsumoto
2018-12-11Rename `ht_foreach_func` to `mrb_hash_foreach_func`.Yukihiro "Matz" Matsumoto
2018-12-11Update comments.Yukihiro "Matz" Matsumoto
2018-12-11Add API function `mrb_hash_foreach()` to iterate over items in a hash.Yukihiro "Matz" Matsumoto
2018-11-19Removed `to_hash` conversion method.Yukihiro "Matz" Matsumoto
2018-11-19Improve Hash table using variable sized segments.Yukihiro "Matz" Matsumoto
2018-11-16The key or value object could be reclaimed by GC; fix #4164Yukihiro "Matz" Matsumoto
The GC may occur between `sg_shift` and `mrb_assoc_new`, in which case `key` and `value` could be freed even tough they are still alive. The issue is found and fixed by https://hackerone.com/hexodus
2018-10-20Need to freeze string keys.Yukihiro "Matz" Matsumoto
2018-10-12Should not compare `undef` (deleted) key in hashes; fix #4136Yukihiro "Matz" Matsumoto
2018-10-12Add `NULL` check in `sg_compact()`; fix #4139Yukihiro "Matz" Matsumoto
2018-10-12`Hash#delete` should return the deleted value; fix #4133Yukihiro "Matz" Matsumoto
2018-09-26Implement `Hash#rehash` in C using `sg_compact()`.Yukihiro "Matz" Matsumoto
2018-09-26Add index to larger segment lists for performanceYukihiro "Matz" Matsumoto
2018-09-26Use `mrb_undef_value` for delete mark instead of shifting Hash entry table.Yukihiro "Matz" Matsumoto
That means entry table should be compacted periodically by `sg_compact()`.
2018-09-26Use segmented list to implement `Hash` [Experimental]Yukihiro "Matz" Matsumoto
I know it's not hash at all, but reduce memory consumption.
2018-09-06Need to check if merging hash is empty; fix #4107Yukihiro "Matz" Matsumoto
2018-08-30Add new function `mrb_ensure_hash_type()`; ref #4097Yukihiro "Matz" Matsumoto
Unlike `mrb_check_hash_type()` that returns `nil` if the argument is not a `Hash`, `mrb_ensure_hash_type()` raises a `TypeError` exception.
2018-08-25Add a new function `mrb_hash_merge()`.Yukihiro "Matz" Matsumoto
2018-07-30Keyword argument implemented.Yukihiro "Matz" Matsumoto
2018-06-01Instead of defining `Hash#dup`, we should define `Hash#initialize_copy`.Yukihiro "Matz" Matsumoto
`Hash#clone` did not work properly; fix #4030
2017-12-12Modifying frozen objects will raise `FrozenError`.Yukihiro "Matz" Matsumoto
`FrozenError` is a subclass of `RuntimeError` which used to be raised. [Ruby2.5]
2017-11-19Leave `hash->ht` to be `NULL` if initial capacity is zero.Yukihiro "Matz" Matsumoto
2017-10-11Add MRB_WITHOUT_FLOATYAMAMOTO Masaya
2017-09-27fix: src\hash.c(139): warning C4244: 'function': conversion from 'mrb_int' ↵Tomasz Dąbrowski
to 'khint_t', possible loss of data
2017-09-27fix: src\hash.c(40): warning C4244: '=': conversion from 'mrb_int' to ↵Tomasz Dąbrowski
'khint_t', possible loss of data
2017-08-10Use standard hash functions in `mrb_hash_ht_hash_func`.Yukihiro "Matz" Matsumoto
2017-08-05Prevented resizing just created hashes in specific size rangesChristopher Aue
2017-08-04Improved speed of creating new hash tablesChristopher Aue
2017-07-27Embed small size array elements in the heap.Yukihiro "Matz" Matsumoto
It reduces the memory consumption and sometimes improve the performance as well. For example, the consumed memory size of `bench/bm_ao_render.rb` is reduced from 1.2GB to 1GB, and its total execution time become 18.795 sec from 22.229 sec.
2017-06-19Use `mrb_int` instead of `int` as argument to `mrb_hash_new_capa`.Yukihiro "Matz" Matsumoto
2017-04-18Hash#dup didn't check if internal khash is initialized; fix #3609Yukihiro "Matz" Matsumoto
2017-04-01Pacify signed warning; ref #3565Yukihiro "Matz" Matsumoto
2017-03-31Avoid crash if hv.n is greater than kh_size(h); fix #3565Yukihiro "Matz" Matsumoto
The resulting behavior is different from CRuby, but modifying hash key afterwards is undefined behavior in ISO spec.