| Commit message (Collapse) | Author | Age | Files | Lines |
| |
|
| |
|
|
|
|
| |
RARRAY_PTR_USE now does the same things as RARRAY_PTR_USE_TRANSIENT.
|
|
|
|
|
|
|
|
| |
According to the C99 specification section 7.20.3.2 paragraph 2:
> If ptr is a null pointer, no action occurs.
So we do not need to check that the pointer is a null pointer.
|
|
|
|
| |
Hash#replace can leak memory if the receiver has an ST table.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
st_copy allocates a st_table, which is not needed for hashes since it is
allocated by VWA and embedded, so this causes a memory leak.
The following script demonstrates the issue:
```ruby
20.times do
100_000.times do
{a: 1, b: 2, c: 3, d: 4, e: 5, f: 6, g: 7, h: 8, i: 9}
end
puts `ps -o rss= -p #{$$}`
end
```
|
| |
|
| |
|
|
|
|
|
| |
RHASH_TABLE_NULL_P and ar_alloc_table are no longer needed since
all Hash will have AR tables.
|
| |
|
| |
|
| |
|
| |
|
|
|
|
|
| |
We now always copy the ST table, so we don't need to initialize the ST
table of hash when hash2 is empty.
|
|
|
|
|
|
|
|
|
| |
With VWA, AR hashes are much larger than ST hashes. Hash#replace
attempts to directly copy the contents of AR hashes into ST hashes so
there will be memory corruption caused by writing past the end of memory.
This commit changes it so that if a ST hash is being replaced with an AR
hash it will insert each element into the ST hash.
|
|
|
|
| |
new_tab can no longer ever be NULL so this is dead code.
|
|
|
|
|
|
|
|
|
|
| |
[Feature #19236]
In Ruby 3.3, `Hash.new` shall print a deprecation warning if keyword arguments
are passed instead of treating them as an implicit positional Hash.
This will allow to safely introduce a `capacity` keyword argument in 3.4
Co-authored-by: Jean Boussier <byroot@ruby-lang.org>
|
|
|
|
| |
This allows Hashes with ST tables to fit int he 80 byte size pool.
|
| |
|
| |
|
| |
|
| |
|
| |
|
|
|
|
|
|
|
| |
[Bug #19589]
When decrementing `iter_lev` from `65` to `64` the flags would be
corrupted, causing the shape_id to be invalid.
|
|
|
|
| |
NEWOBJ_OF is now our canonical newobj macro. It takes an optional ec
|
|
|
|
|
|
|
|
|
| |
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]
|
|
|
|
|
|
|
| |
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]
|
|
|
|
|
|
|
|
| |
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]
|
| |
|
| |
|
|
|
|
| |
[Feature #18498]
|
| |
|
|
|
|
| |
[Feature #19425]
|
|
|
|
|
|
| |
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.
|
|
|
|
| |
Hashes can only be ar or st, so the else if is redundant.
|
|
|
|
| |
It's dead code and duplicate of RHASH_AR_TABLE_P.
|
|
|
|
| |
It's a duplicate of RHASH_ST_TABLE.
|
|
|
|
| |
It's dead code and duplicate of RHASH_AR_TABLE.
|
|
|
|
| |
Fixes [Bug #19237]
|
|
|
|
|
|
|
|
|
|
| |
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.
|
|
|
|
|
|
|
|
|
| |
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.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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>
|
| |
|
| |
|
| |
|
| |
|
|
|
|
|
|
| |
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.
|
|
|
|
|
|
| |
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.
|
|
|
|
| |
[Misc #18891]
|
| |
|