Commit graph

1088 commits

Author SHA1 Message Date
BurdetteLamar
a870419f3a [DOC] Tweaks for Hash#inspect 2025-02-26 09:27:55 -05:00
BurdetteLamar
8749a131ce [DOC] Tweaks for Hash#include? 2025-02-24 19:27:41 -05:00
BurdetteLamar
0615df2a84 [DOC] Tweaks for Hash#hash 2025-02-24 19:27:31 -05:00
Burdette Lamar
19f7961e46
[DOC] Tweaks for Hash#flatten 2025-02-24 19:26:50 -05:00
BurdetteLamar
4129973005 [DOC] Tweaks for Hash#fetch_values 2025-02-21 11:53:51 -05:00
BurdetteLamar
273e35cdcc [DOC] Tweaks for Hash#fetch 2025-02-19 09:46:52 -05:00
BurdetteLamar
a46997a8f7 [DOC] Tweaks for Hash#except 2025-02-19 09:46:04 -05:00
Burdette Lamar
188b3375b0
[DOC] Tweaks for Hash#eql? 2025-02-19 09:45:27 -05:00
Nobuyoshi Nakada
3f07bc76ff [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.
2025-02-19 18:27:32 +09:00
Burdette Lamar
27ba268b75
[DOC] Tweaks for Hash#empty? 2025-02-18 15:29:27 -05:00
BurdetteLamar
fd134cf6d2 [DOC] Tweaks for Hash#each_value 2025-02-18 15:02:05 -05:00
BurdetteLamar
eafcdc1535 [DOC] Tweaks for Hash#each_key 2025-02-18 10:04:58 -05:00
BurdetteLamar
36f69d5b69 [DOC] Tweaks for Hash#dig 2025-02-17 19:09:33 -05:00
BurdetteLamar
266088a85a [DOC] Tweaks for Hash#each_pair 2025-02-17 19:08:14 -05:00
BurdetteLamar
047a05ea43 [DOC] Tweaks for Hash#delete_if 2025-02-17 19:06:22 -05:00
Burdette Lamar
8324e3148a
[DOC] Tweaks for Hash#compact! (#12756) 2025-02-17 11:10:48 -05:00
BurdetteLamar
2b69949407 [DOC] Tweaks for Hash#delete 2025-02-16 13:01:17 -05:00
BurdetteLamar
0a10c9bed6 [DOC] Tweaks for Hash#compare_by_identity 2025-02-16 12:59:14 -05:00
BurdetteLamar
a94f00f7c1 [DOC] Add Related notes to a few methods 2025-02-16 12:57:23 -05:00
BurdetteLamar
e3ad652490 [DOC] Tweaks for Hash#compact 2025-02-16 12:56:48 -05:00
Burdette Lamar
ba148e71e5
[DOC] Tweaks for Hash#[] 2025-02-14 16:16:53 -05:00
Burdette Lamar
9be6e4207b
[DOC] Tweaks for Hash#[]= (#12695) 2025-02-14 15:55:10 -05:00
Jean Boussier
f32d5071b7 Elide string allocation when using String#gsub in MAP mode
If the provided Hash doesn't have a default proc, we know for
sure that we'll never call into user provided code, hence the
string we allocate to access the Hash can't possibly escape.

So we don't actually have to allocate it, we can use a fake_str,
AKA a stack allocated string.

```
compare-ruby: ruby 3.5.0dev (2025-02-10T13:47:44Z master 3fb455adab) +PRISM [arm64-darwin23]
built-ruby: ruby 3.5.0dev (2025-02-10T17:09:52Z opt-gsub-alloc ea5c28958f) +PRISM [arm64-darwin23]
warming up....

|                 |compare-ruby|built-ruby|
|:----------------|-----------:|---------:|
|escape           |      3.374k|    3.722k|
|                 |           -|     1.10x|
|escape_bin       |      5.469k|    6.587k|
|                 |           -|     1.20x|
|escape_utf8      |      3.465k|    3.734k|
|                 |           -|     1.08x|
|escape_utf8_bin  |      5.752k|    7.283k|
|                 |           -|     1.27x|
```
2025-02-12 10:23:50 +01:00
Peter Zhu
eada3cdf89 [DOC] Fix call-seq consistency in Hash
The documentation guide (https://docs.ruby-lang.org/en/master/contributing/documentation_guide_md.html#label-Calling+Sequence+-28for+methods+written+in+C-29)
says that the call-seq for instance methods should only include the method
name, no prepending `hash.`.
2025-02-10 16:30:04 -05:00
Burdette Lamar
b4bf3ed130
[DOC] Adds section "Hash Inclusion" (#12634) 2025-02-10 14:32:25 -05:00
Burdette Lamar
7fd589c7fc
[DOC] Tweaks for Hash#assoc (#12726) 2025-02-10 14:31:41 -05:00
Burdette Lamar
57b9b92193
[DOC] Tweaks for Hash#clear (#12727) 2025-02-10 14:31:04 -05:00
Burdette Lamar
35afc0d6e1
[DOC] Tweaks for Hash#any? 2025-02-10 14:23:42 -05:00
Burdette Lamar
d3bb42776c
[DOC] Tweaks for rb_hash_s_try_convert 2025-01-29 10:16:47 -05:00
BurdetteLamar
b346b49744 [DOC] Tweaks for rb_hash_s_create 2025-01-26 16:54:57 -05:00
Burdette Lamar
6f6654e504
[DOC] Hash defaults doc 2025-01-22 15:12:53 -05:00
Petrik de Heus
5045c666db
[DOC] Use Hash inspect without hash-rocket in Hash documentation (#12540)
Co-authored-by: tomoya ishida <tomoyapenguin@gmail.com>
2025-01-10 00:21:28 +09:00
BurdetteLamar
6b2b537e35 [DOC] Tweaks for Hash::[] 2025-01-03 14:56:43 -05:00
Nobuyoshi Nakada
e433e6515e
[DOC] Exclude 'Class' and 'Module' from RDoc's autolinking 2025-01-02 12:36:06 +09:00
Nobuyoshi Nakada
b4ec22fe6c
[DOC] Exclude 'Method' from RDoc's autolinking 2025-01-02 12:23:49 +09:00
Nobuyoshi Nakada
c6dbb10b74
[Bug #20982] Put spaces in ENV.inspect results as well as Hash 2024-12-26 15:01:48 +09:00
Nobuyoshi Nakada
19c39e4cfa
[Bug #20984] ENV.inspect should be encoding aware 2024-12-26 13:42:56 +09:00
tomoya ishida
477c505ac0
[DOC] Fix output examples containing old Hash#inspect format
The inspect format was intentionally changed as an outcome of
[Bug #20433] [ruby-core:118668], but some documentation update
was missing, as [Bug #20962] pointed out. Update some output
examples that clearly use Hash#inspect.
2024-12-18 12:08:15 -05:00
tompng
a8a0591253 Hash#inspect with colon style 2024-10-03 18:47:09 +09:00
ydah
0c25eb4ffe s/interation/iteration/ 2024-09-27 09:58:32 +09:00
ydah
cc1e1e77d5 s/useable/usable/ 2024-09-26 20:01:20 +09:00
Lars Kanis
acf28e835f Windows: Use Unicode aware WinAPI function for ENV[]=
This only makes a difference when setting an empty value to a Unicode key.
2024-09-24 14:06:51 +09:00
Lars Kanis
7627a95e41 Windows: Remove ENV code targeting Windows before Vista
Windows Vista removed the limit to 32768 bytes environment block.
Also MINGW supports _wputenv_s() for years.
2024-09-24 14:06:51 +09:00
Étienne Barrié
bf9879791a Optimized instruction for Hash#freeze
If a Hash which is empty or only using literals is frozen, we detect
this as a peephole optimization and change the instructions to be
`opt_hash_freeze`.

[Feature #20684]

Co-authored-by: Jean Boussier <byroot@ruby-lang.org>
2024-09-05 12:46:02 +02:00
BurdetteLamar
a85dc3e972 [DOC] Rationalize aliases 2024-08-30 22:25:47 -04:00
Yusuke Endoh
ac5ac48a36 Revert 28a1c4f33e
28a1c4f33e seems to call an improper
ensure clause. [Bug #20655]
Than fixing it properly, I bet it would be much better to simply revert
that commit. It reduces the unneeded complexity. Jumping into a block
called by a C function like Hash#each with callcc is user's fault.
It does not need serious support.
2024-07-30 15:31:24 +09:00
Jean Boussier
9594db0cf2 Implement Hash.new(capacity:)
[Feature #19236]

When building a large hash, pre-allocating it with enough
capacity can save many re-hashes and significantly improve
performance.

```
/opt/rubies/3.3.0/bin/ruby --disable=gems -rrubygems -I./benchmark/lib ./benchmark/benchmark-driver/exe/benchmark-driver \
	            --executables="compare-ruby::../miniruby-master -I.ext/common --disable-gem" \
	            --executables="built-ruby::./miniruby --disable-gem" \
	            --output=markdown --output-compare -v $(find ./benchmark -maxdepth 1 -name 'hash_new' -o -name '*hash_new*.yml' -o -name '*hash_new*.rb' | sort)
compare-ruby: ruby 3.4.0dev (2024-03-25T11:48:11Z master f53209f023) +YJIT dev [arm64-darwin23]
last_commit=[ruby/irb] Cache RDoc::RI::Driver.new (https://github.com/ruby/irb/pull/911)
built-ruby: ruby 3.4.0dev (2024-03-25T15:29:40Z hash-new-rb 77652b08a2) +YJIT dev [arm64-darwin23]
warming up...

|                    |compare-ruby|built-ruby|
|:-------------------|-----------:|---------:|
|new                 |      7.614M|    5.976M|
|                    |       1.27x|         -|
|new_with_capa_1k    |     13.931k|   15.698k|
|                    |           -|     1.13x|
|new_with_capa_100k  |     124.746|   148.283|
|                    |           -|     1.19x|
```
2024-07-08 12:24:33 +02:00
Nobuyoshi Nakada
f36a71e269 [Bug #20307] Fix Hash#update to make frozen copy of string keys 2024-03-14 17:49:37 +09:00
Nobuyoshi Nakada
cd774f4ab9 Extract RHASH_STRING_KEY_P 2024-03-14 17:49:37 +09:00
Nobuyoshi Nakada
c1279a3da5 Extract RHASH_IDENTHASH_P 2024-03-14 17:49:37 +09:00