summaryrefslogtreecommitdiff
path: root/hash.c
Commit message (Collapse)AuthorAgeFilesLines
* Move ar_hint to ar_table_structPeter Zhu2023-05-171-14/+17
| | | | This allows Hashes with ST tables to fit int he 80 byte size pool.
* Implement Hash ST tables on VWAPeter Zhu2023-05-171-71/+39
|
* Implement Hash AR tables on VWAPeter Zhu2023-05-171-77/+22
|
* Add `rb_sys_fail_sprintf` macroNobuyoshi Nakada2023-05-121-4/+4
|
* [DOC] hash.c: fix typo in `#<=>` docsPiotr Szotkowski2023-05-011-1/+1
|
* Adjust function style [ci skip]Nobuyoshi Nakada2023-04-151-3/+1
|
* hash.c: Fix hash_iter_lev_dec corrupting shapeJean Boussier2023-04-111-3/+9
| | | | | | | [Bug #19589] When decrementing `iter_lev` from `65` to `64` the flags would be corrupted, causing the shape_id to be invalid.
* [Feature #19474] Refactor NEWOBJ macrosMatt Valentine-House2023-04-061-1/+1
| | | | NEWOBJ_OF is now our canonical newobj macro. It takes an optional ec
* Change Hash#compact to keep default values and compare_by_identity flagJeremy Evans2023-03-241-11/+5
| | | | | | | | | The documentation states it returns a copy of self with nil value entries removed. However, the previous behavior was creating a plain new hash with non-nil values copied into it. This change aligns the behavior with the documentation. Fixes [Bug #19113]
* Copy compare_by_identity flag for empty hashes in Hash.ruby2_keywords_hashJeremy Evans2023-03-241-3/+6
| | | | | | | This was already copied for non-empty hashes. As Hash.ruby2_keywords_hash copies default values, it should also copy the compare_by_identity flag. Partially Fixes [Bug #19113]
* Do not copy compare_by_identity flag for non-empty hashes in Hash.[]Jeremy Evans2023-03-241-4/+16
| | | | | | | | It wasn't copied for empty hashes, and Hash.[] doesn't copy the default value, so copying the compare_by_identity flag does not make sense. Partially Fixes [Bug #19113]
* Resurrect symbols used by ObjectSpaceTakashi Kokubun2023-03-061-1/+1
|
* Stop exporting symbols for MJITTakashi Kokubun2023-03-061-8/+8
|
* Implement ObjectSpace::WeakKeyMap basic allocatorJean Boussier2023-02-231-2/+2
| | | | [Feature #18498]
* Remove (newly unneeded) remarks about aliasesBurdetteLamar2023-02-191-26/+2
|
* Merge gc.h and internal/gc.hMatt Valentine-House2023-02-091-1/+1
| | | | [Feature #19425]
* Remove dead code in ar_copyPeter Zhu2023-02-031-32/+16
| | | | | | All of the callers of ar_copy guarantee that hash2 has an ar table, so we don't need the logic to handle the case when hash2 doesn't have an ar table.
* Remove redundant else if statement in hash.cPeter Zhu2023-02-021-2/+4
| | | | Hashes can only be ar or st, so the else if is redundant.
* Remove rb_hash_ar_table_pPeter Zhu2023-01-311-12/+0
| | | | It's dead code and duplicate of RHASH_AR_TABLE_P.
* Remove rb_hash_st_tablePeter Zhu2023-01-311-7/+0
| | | | It's a duplicate of RHASH_ST_TABLE.
* Remove rb_hash_ar_tablePeter Zhu2023-01-311-7/+0
| | | | It's dead code and duplicate of RHASH_AR_TABLE.
* Document thread-safety issues with Hash default_procJeremy Evans2023-01-201-0/+4
| | | | Fixes [Bug #19237]
* Assert possible hash functions in RHASH_ST_TABLE (#7107)Takashi Kokubun2023-01-111-0/+4
| | | | | | | | | | Because of the function pointer, it's hard to figure out what hash functions could be used in Hash objects when st_lookup is used. Having this assertion makes it easier to understand what hash_stlike_lookup could possibly do. (AR uses only rb_any_hash) For example, this clarifies that hash_stlike_lookup never calls a #hash method when a key is T_STRING or T_SYMBOL.
* Use FL_TEST_RAW in rb_hash_default_valueJohn Hawthorn2022-12-171-1/+3
| | | | | | | | | We should always have a T_HASH here, so we can use FL_TEST_RAW to avoid checking whether we may have an immediate value. I expect this to be a very small performance improvement (perf stat ./miniruby benchmark/hash_aref_miss.rb shows a ~1% improvement). It also removes 9 instructions from rb_hash_default_value on x86_64.
* Use a BOP for Hash#defaultJohn Hawthorn2022-12-171-3/+17
| | | | | | | | | | | | | | | | | | | | On a hash miss we need to call default if it is redefined in order to return the default value to be used. Previously we checked this with rb_method_basic_definition_p, which avoids the method call but requires a method lookup. This commit replaces the previous check with BASIC_OP_UNREDEFINED_P and a new BOP_DEFAULT. We still need to fall back to rb_method_basic_definition_p when called on a subclasss of hash. | |compare-ruby|built-ruby| |:---------------|-----------:|---------:| |hash_aref_miss | 2.692| 3.531| | | -| 1.31x| Co-authored-by: Daniel Colson <danieljamescolson@gmail.com> Co-authored-by: "Ian C. Anderson" <ian@iancanderson.com> Co-authored-by: Jack McCracken <me@jackmc.xyz>
* Using UNDEF_P macroS-H-GAMELINKS2022-11-161-15/+15
|
* Adjust indents [ci skip]Nobuyoshi Nakada2022-10-241-13/+13
|
* Introduce `hash_iter_status_check` functionS.H2022-10-231-18/+15
|
* Improved formatting of `hash_foreach_iter` functions. (#6615)Samuel Williams2022-10-221-7/+10
|
* [Bug #17767] Now `ENV.clone` raises `TypeError` as well as `ENV.dup`Nobuyoshi Nakada2022-08-021-13/+8
| | | | | | One year ago, the former method has been deprecated while the latter has become an error. Then the 3.1 released, it is enough time to make also the former an error.
* Rename rb_ary_tmp_new to rb_ary_hidden_newPeter Zhu2022-07-261-1/+1
| | | | | | rb_ary_tmp_new suggests that the array is temporary in some way, but that's not true, it just creates an array that's hidden and not on the transient heap. This commit renames it to rb_ary_hidden_new.
* Expand tabs [ci skip]Takashi Kokubun2022-07-211-273/+273
| | | | [Misc #18891]
* ENV.merge! support multile arguments [Feature #18279]Nobuyoshi Nakada2022-06-171-10/+15
|
* Restore rb_exec_recursive_outerJohn Hawthorn2022-06-151-0/+1
| | | | This was a public method, so we should probably keep it.
* Make method id explicit in rb_exec_recursive_outerJohn Hawthorn2022-06-101-1/+1
| | | | | | | | | | | | | | Previously, because opt_aref and opt_aset don't push a frame, when they would call rb_hash to determine the hash value of the key, the initial level of recursion would incorrectly use the method id at the top of the stack instead of "hash". This commit replaces rb_exec_recursive_outer with rb_exec_recursive_outer_mid, which takes an explicit method id, so that we can make the hash calculation behave consistently. rb_exec_recursive_outer was documented as being internal, so I believe this should be okay to change.
* Document best-practices for writing hash methods (#5805)Chris Seaton2022-04-301-0/+13
| | | | | * Discussion is as per https://bugs.ruby-lang.org/issues/18611. Co-authored-by: Sam Bostock <sam.bostock@shopify.com>
* Expose `rb_hash_new_capa(long)`Jean Boussier2022-04-261-0/+6
| | | | | | | | [Feature #18683] This allows parsers and similar libraries to create Hashes of a certain capacity in advance. It's useful when the key and values are streamed, hence `bulk_insert()` can't be used.
* [DOC] Use simple references to operator methodsNobuyoshi Nakada2022-03-261-4/+4
| | | | | | | Method references is not only able to be marked up as code, also reflects `--show-hash` option. The bug that prevented the old rdoc from correctly parsing these methods was fixed last month.
* Fix formatting errors in What's Here for Array, Hash, ENV (#5718)Burdette Lamar2022-03-251-113/+113
|
* [DOC] Simplify operator method referencesNobuyoshi Nakada2022-02-121-5/+5
|
* Fix TypoSteven Nunez2022-02-121-1/+1
|
* [DOC] Fix broken links to literals.rdocNobuyoshi Nakada2022-02-081-1/+1
|
* [DOC] Simplify links to global methodsNobuyoshi Nakada2022-02-081-1/+1
|
* [DOC] Use RDoc link style for links in the same class/modulePeter Zhu2022-02-071-49/+49
| | | | | | | | | | I used this regex: (?<=\[)#(?:class|module)-([A-Za-z]+)-label-([A-Za-z0-9\-\+]+) And performed a global find & replace for this: rdoc-ref:$1@$2
* [DOC] Use RDoc link style for links to other classes/modulesPeter Zhu2022-02-071-4/+4
| | | | | | | | | | I used this regex: ([A-Za-z]+)\.html#(?:class|module)-[A-Za-z]+-label-([A-Za-z0-9\-\+]+) And performed a global find & replace for this: rdoc-ref:$1@$2
* [Bug #18501] Fire write barrier after hash has been writtenAaron Patterson2022-02-041-5/+15
| | | | | | | | | | | | | | | | | Before this change the write barrier was executed before the key and value were actually reachable via the Hash. This could cause inconsistencies in object coloration which would lead to accidental collection of dup'd keys. Example: 1. Object O is grey, Object P is white. 2. Write barrier fires O -> P 3. Write barrier does nothing 4. Malloc happens, which starts GC 5. GC colors O black 6. P is written in to O (now we have O -> P reference) 7. P is now accidentally treated as garbage
* Make Hash#shift return nil for empty hashJeremy Evans2022-01-141-4/+3
| | | | Fixes [Bug #16908]
* Remove tainted and trusted featuresNobuyoshi Nakada2021-12-261-7/+0
| | | | Already these had been announced to be removed in 3.2.
* Add missing '%' in format stringKazuhiro NISHIYAMA2021-12-211-1/+1
|
* [DOC] Add documentation for hash value omission syntaxVictor Shepelev2021-12-201-0/+8
|