summaryrefslogtreecommitdiff
path: root/hash.c
AgeCommit message (Collapse)Author
2025-03-10merge revision(s) 3f07bc76ff6a11232d9f18e5eaa31835c195e8f0, ↵Hiroshi SHIBATA
34098b669c0cbc024cd08e686891f1dfe0a10aaf: [Backport #21144] [Bug #21144] Win32: Use Windows time zone ID if TZ is not set If the TZ environment variable is not set, the time zone names retrieved from the system are localized for UI display and may vary across editions and language packs for the same time zone. Use the time zone IDs that are invariant across environments instead. [Bug #21144] Win32: Convert the time zone name to the current locale The Windows time zone IDs provided by Microsoft as of 24H1 are ASCII only all, but the API itself is not impossible to set non-ASCII key name. Prefer the current locale encoding for now until we move to UTF-8 including environment variables and command line arguments.
2025-01-11merge revision(s) 19c39e4cfaa467e69b9848c9c5496d7f50d39c7f, ↵nagachika
d78ff6a767ca813ac5fa178dd7611f20a993c191: [Backport #20984] [Bug #20984] ENV.inspect should be encoding aware [Bug #20984] Fix test with locale encoding
2024-11-10backport 2a5354e59324cb296a423c73ec15ff9191086964 partially to make ↵nagachika
rb_any_hash() non-static.
2024-07-13follow-up for 3faef1d40dc1d6eea8ffcd624528f431ccaf0a5b.nagachika
2024-07-13merge revision(s) f36a71e26995b69ff72bc132bbcf40ad89571414: [Backport #20307]nagachika
[Bug #20307] Fix `Hash#update` to make frozen copy of string keys
2024-07-13Extract `RHASH_STRING_KEY_P`Nobuyoshi Nakada
2024-07-13Extract `RHASH_IDENTHASH_P`Nobuyoshi Nakada
2024-04-08Backport https://github.com/ruby/ruby/pull/9240 to Ruby 3.2KJ Tsanaktsidis
Merged into master in 7ba2506232d3fa6c4e82e3708c0ff746a1a8de5c [Bug #20050]
2023-11-19merge revision(s) 9eac9d71786a8dbec520d0541a91149f01adf8ea: [Backport #19969]nagachika
[Bug #19969] Compact st_table after deleted if possible --- hash.c | 19 +++++++++++++++++++ st.c | 40 +++++++++++++++++++++++++++++----------- test/ruby/test_hash.rb | 9 +++++++++ 3 files changed, 57 insertions(+), 11 deletions(-)
2023-07-17merge revision(s) 8c360ce713f57d4177de833297364f6f6d950420: [Backport #19589]nagachika
hash.c: Fix hash_iter_lev_dec corrupting shape [Bug #19589] When decrementing `iter_lev` from `65` to `64` the flags would be corrupted, causing the shape_id to be invalid. --- hash.c | 12 +++++++++--- test/ruby/test_hash.rb | 11 +++++++++++ 2 files changed, 20 insertions(+), 3 deletions(-)
2022-12-17Use FL_TEST_RAW in rb_hash_default_valueJohn Hawthorn
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. Notes: Merged: https://github.com/ruby/ruby/pull/6945
2022-12-17Use a BOP for Hash#defaultJohn Hawthorn
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> Notes: Merged: https://github.com/ruby/ruby/pull/6945
2022-11-16Using UNDEF_P macroS-H-GAMELINKS
Notes: Merged: https://github.com/ruby/ruby/pull/6721
2022-10-24Adjust indents [ci skip]Nobuyoshi Nakada
2022-10-23Introduce `hash_iter_status_check` functionS.H
Notes: Merged: https://github.com/ruby/ruby/pull/6564 Merged-By: nobu <nobu@ruby-lang.org>
2022-10-22Improved formatting of `hash_foreach_iter` functions. (#6615)Samuel Williams
Notes: Merged-By: ioquatix <samuel@codeotaku.com>
2022-08-02[Bug #17767] Now `ENV.clone` raises `TypeError` as well as `ENV.dup`Nobuyoshi Nakada
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. Notes: Merged: https://github.com/ruby/ruby/pull/6155
2022-07-26Rename rb_ary_tmp_new to rb_ary_hidden_newPeter Zhu
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. Notes: Merged: https://github.com/ruby/ruby/pull/6180
2022-07-21Expand tabs [ci skip]Takashi Kokubun
[Misc #18891] Notes: Merged: https://github.com/ruby/ruby/pull/6094
2022-06-17ENV.merge! support multile arguments [Feature #18279]Nobuyoshi Nakada
Notes: Merged: https://github.com/ruby/ruby/pull/5207
2022-06-15Restore rb_exec_recursive_outerJohn Hawthorn
This was a public method, so we should probably keep it. Notes: Merged: https://github.com/ruby/ruby/pull/6027
2022-06-10Make method id explicit in rb_exec_recursive_outerJohn Hawthorn
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. Notes: Merged: https://github.com/ruby/ruby/pull/6004
2022-04-30Document best-practices for writing hash methods (#5805)Chris Seaton
* Discussion is as per https://bugs.ruby-lang.org/issues/18611. Co-authored-by: Sam Bostock <sam.bostock@shopify.com> Notes: Merged-By: eregon <eregontp@gmail.com>
2022-04-26Expose `rb_hash_new_capa(long)`Jean Boussier
[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. Notes: Merged: https://github.com/ruby/ruby/pull/5835
2022-03-26[DOC] Use simple references to operator methodsNobuyoshi Nakada
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.
2022-03-25Fix formatting errors in What's Here for Array, Hash, ENV (#5718)Burdette Lamar
Notes: Merged-By: BurdetteLamar <BurdetteLamar@Yahoo.com>
2022-02-12[DOC] Simplify operator method referencesNobuyoshi Nakada
2022-02-12Fix TypoSteven Nunez
Notes: Merged: https://github.com/ruby/ruby/pull/5548
2022-02-08[DOC] Fix broken links to literals.rdocNobuyoshi Nakada
2022-02-08[DOC] Simplify links to global methodsNobuyoshi Nakada
2022-02-07[DOC] Use RDoc link style for links in the same class/modulePeter Zhu
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 Notes: Merged: https://github.com/ruby/ruby/pull/5530
2022-02-07[DOC] Use RDoc link style for links to other classes/modulesPeter Zhu
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 Notes: Merged: https://github.com/ruby/ruby/pull/5530
2022-02-04[Bug #18501] Fire write barrier after hash has been writtenAaron Patterson
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 Notes: Merged: https://github.com/ruby/ruby/pull/5525
2022-01-14Make Hash#shift return nil for empty hashJeremy Evans
Fixes [Bug #16908] Notes: Merged: https://github.com/ruby/ruby/pull/5360
2021-12-26Remove tainted and trusted featuresNobuyoshi Nakada
Already these had been announced to be removed in 3.2. Notes: Merged: https://github.com/ruby/ruby/pull/5348
2021-12-21Add missing '%' in format stringKazuhiro NISHIYAMA
2021-12-20[DOC] Add documentation for hash value omission syntaxVictor Shepelev
Notes: Merged: https://github.com/ruby/ruby/pull/5244 Merged-By: nobu <nobu@ruby-lang.org>
2021-12-18What's Here for ENV (#5292)Burdette Lamar
[DOC] What's Here for ENV Notes: Merged-By: BurdetteLamar <BurdetteLamar@Yahoo.com>
2021-12-17data type should be `static`Koichi Sasada
Notes: Merged: https://github.com/ruby/ruby/pull/5288
2021-12-17`RUBY_DEFAULT_FREE` is not needed.Koichi Sasada
pointed by @nobu. Notes: Merged: https://github.com/ruby/ruby/pull/5288
2021-12-17`ENV` ivars should not be accessible from ractorsKoichi Sasada
The `ENV` object can have instance variables like other objects, but they should be accessed only on the main ractor. fix https://github.com/ruby/ruby/pull/5263#issuecomment-995585766 Notes: Merged: https://github.com/ruby/ruby/pull/5288
2021-12-16Suppress empty-body warningNobuyoshi Nakada
2021-12-15Adjust indents [ci skip]Nobuyoshi Nakada
2021-12-15use `RB_VM_LOCK_ENTER()`Koichi Sasada
We found that we need to make Ruby objects while locking the environ to ENV operation atomically, so we decided to use `RB_VM_LOCK_ENTER()` instead of `env_lock`. Notes: Merged: https://github.com/ruby/ruby/pull/5263
2021-12-15Removed no longer used variablesNobuyoshi Nakada
Notes: Merged: https://github.com/ruby/ruby/pull/5263
2021-12-15Fixed env_pairs array typesNobuyoshi Nakada
Notes: Merged: https://github.com/ruby/ruby/pull/5263
2021-12-15Use prototype definition instead of old K&R styleNobuyoshi Nakada
Notes: Merged: https://github.com/ruby/ruby/pull/5263
2021-12-15Adjust styles [ci skip]Nobuyoshi Nakada
* --braces-after-func-def-line * --space-after-for Notes: Merged: https://github.com/ruby/ruby/pull/5263
2021-12-15Symbols closed to env should be staticNobuyoshi Nakada
Notes: Merged: https://github.com/ruby/ruby/pull/5263
2021-12-15Make ENV shareableRohit Menon
Notes: Merged: https://github.com/ruby/ruby/pull/5263