summaryrefslogtreecommitdiff
path: root/hash.c
AgeCommit message (Collapse)Author
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
2021-12-15Move exception-raising functions out of mutex; Refactor env-copyingRohit Menon
Notes: Merged: https://github.com/ruby/ruby/pull/5263
2021-12-15Add locks for ENVRohit Menon
Notes: Merged: https://github.com/ruby/ruby/pull/5263
2021-12-03Adding links to literals and Kernel (#5192)Burdette Lamar
* Adding links to literals and Kernel Notes: Merged-By: BurdetteLamar <BurdetteLamar@Yahoo.com>
2021-11-08[Feature #18290] Remove all usages of rb_gc_force_recyclePeter Zhu
This commit removes usages of rb_gc_force_recycle since it is a burden to maintain and makes changes to the GC difficult. Notes: Merged: https://github.com/ruby/ruby/pull/4363
2021-10-02Restore Hash#compare_by_identity mode [Bug #18171]Nobuyoshi Nakada
Notes: Merged: https://github.com/ruby/ruby/pull/4893
2021-10-02Add rb_ident_hash_new_with_sizeNobuyoshi Nakada
Notes: Merged: https://github.com/ruby/ruby/pull/4893
2021-09-30Use faster any_hash logic in rb_hashJohn Hawthorn
From the documentation of rb_obj_hash: > Certain core classes such as Integer use built-in hash calculations and > do not call the #hash method when used as a hash key. So if you override, say, Integer#hash it won't be used from rb_hash_aref and similar. This avoids method lookups in many common cases. This commit uses the same optimization in rb_hash, a method used internally and in the C API to get the hash value of an object. Usually this is used to build the hash of an object based on its elements. Previously it would always do a method lookup for 'hash'. This is primarily intended to speed up hashing of Arrays and Hashes, which call rb_hash for each element. compare-ruby: ruby 3.0.1p64 (2021-04-05 revision 0fb782ee38) [x86_64-linux] built-ruby: ruby 3.1.0dev (2021-09-29T02:13:24Z fast_hash d670bf88b2) [x86_64-linux] # Iteration per second (i/s) | |compare-ruby|built-ruby| |:----------------|-----------:|---------:| |hash_aref_array | 1.008| 1.769| | | -| 1.76x| Notes: Merged: https://github.com/ruby/ruby/pull/4916
2021-09-15[DOC] Fix broken links [ci skip]Nobuyoshi Nakada
* As the "doc/" prefix is specified by the `--page-dir` option, remove from the rdoc references. * Refer to the original .rdoc instead of the converted .html.
2021-09-14Handle overwriting Object::ENV in spawnJeremy Evans
Instead of looking for Object::ENV (which can be overwritten), directly look for the envtbl variable. As that is static in hash.c, and the lookup code is in process.c, add a couple non-static functions that will return envtbl (or envtbl#to_hash). Fixes [Bug #18164] Notes: Merged: https://github.com/ruby/ruby/pull/4834
2021-09-14Revert "Force recycle intermediate collection in Hash#transform_keys! [Bug ↵Kenichi Kamiya
#17735]" This reverts commit 522d4cd32f7727886f4fcbc28ed29c08d361ee20. Notes: Merged: https://github.com/ruby/ruby/pull/4341
2021-09-11Using RB_BIGNUM_TYPE_P macroS-H-GAMELINKS
Notes: Merged: https://github.com/ruby/ruby/pull/4805
2021-08-29Free previously used tables [Bug #18134]Nobuyoshi Nakada
Notes: Merged: https://github.com/ruby/ruby/pull/4788
2021-08-26Make Hash#each family usable in RactorSutou Kouhei
We don't need to increment/decrement iteration level for frozen Hash because frozen Hash can't be modified. We can assume that nobody changes the target Hash while calling #each family. How to reproduce: a = {} 100.times do |i| a[i] = true end Ractor.make_shareable(a) 4.times.collect do Ractor.new(a) do |b| 100.times do b.each_value do end end end end.each(&:take) Example output: internal:ractor>:267: warning: Ractor is experimental, and the behavior may change in future versions of Ruby! Also there are many implementation issues. #<Thread:0x00007fcfb087bb30 run> terminated with exception (report_on_exception is true): #<Thread:0x00007fcfb087b8d8 run> terminated with exception (report_on_exception is true): #<Thread:0x00007fcfb088d678 run> terminated with exception (report_on_exception is true): #<Thread:0x00007fcfb087bd88 run> terminated with exception (report_on_exception is true): /tmp/h.rb:10:in `each_value'/tmp/h.rb:10:in `each_value': : /tmp/h.rb:10:in `each_value'no implicit conversion from nil to integer/tmp/h.rb:10:in `each_value'no implicit conversion from nil to integer (: : (TypeErrorTypeError)no implicit conversion from nil to integer)no implicit conversion from nil to integer ( (TypeErrorTypeError from /tmp/h.rb:10:in `block (3 levels) in <main>' from /tmp/h.rb:10:in `block (3 levels) in <main>' )) from /tmp/h.rb:9:in `times' from /tmp/h.rb:9:in `times' from /tmp/h.rb:9:in `block (2 levels) in <main>' from /tmp/h.rb:10:in `block (3 levels) in <main>' from /tmp/h.rb:10:in `block (3 levels) in <main>' from /tmp/h.rb:9:in `block (2 levels) in <main>' from /tmp/h.rb:9:in `times' from /tmp/h.rb:9:in `times' from /tmp/h.rb:9:in `block (2 levels) in <main>' from /tmp/h.rb:9:in `block (2 levels) in <main>' <internal:ractor>:694:in `take': thrown by remote Ractor. (Ractor::RemoteError) from /tmp/h.rb:14:in `each' from /tmp/h.rb:14:in `<main>' /tmp/h.rb:10:in `each_value': no implicit conversion from nil to integer (TypeError) from /tmp/h.rb:10:in `block (3 levels) in <main>' from /tmp/h.rb:9:in `times' from /tmp/h.rb:9:in `block (2 levels) in <main>' Notes: Merged: https://github.com/ruby/ruby/pull/4768
2021-08-19Remove old warning aged nearly 8 yearsNobuyoshi Nakada
2021-08-07Stop force-recycling evacuated array [Bug #18065]Nobuyoshi Nakada
2021-08-02Using RBOOL macroS.H
Notes: Merged: https://github.com/ruby/ruby/pull/4695 Merged-By: nobu <nobu@ruby-lang.org>
2021-07-28Fix a comment [ci skip]Nobuyoshi Nakada
2021-07-22Remove useless castsNobuyoshi Nakada
2021-07-15Copy hash compare_by_identity setting in more casesJeremy Evans
This makes the compare_by_identity setting always copied for the following methods: * except * merge * reject * select * slice * transform_values Some of these methods did not copy the setting, or only copied the setting if the receiver was not empty. Fixes [Bug #17757] Co-authored-by: Kenichi Kamiya <kachick1@gmail.com> Notes: Merged: https://github.com/ruby/ruby/pull/4616 Merged-By: jeremyevans <code@jeremyevans.net>
2021-07-04[DOC] `Hash.[]` returns a hash with no default value/proc [ci skip]Nobuyoshi Nakada
2021-06-30Specify version to remove as bare numbersNobuyoshi Nakada
Notes: Merged: https://github.com/ruby/ruby/pull/3972
2021-06-30rb_warn_deprecated_to_remove_at [Feature #17432]Nobuyoshi Nakada
At compilation time with RUBY_DEBUG enabled, check if the removal version has been reached. Notes: Merged: https://github.com/ruby/ruby/pull/3972
2021-06-28Share freeze option handlingNobuyoshi Nakada
2021-06-24[DOC] fixed return value of ENV.clone [ci skip]Nobuyoshi Nakada
2021-06-21What's Here for Numeric and ComparableBurdette Lamar
2021-06-17Adjust styles [ci skip]Nobuyoshi Nakada
* --braces-after-func-def-line * --dont-cuddle-else * --procnames-start-lines * --space-after-for * --space-after-if * --space-after-while