Граф коммитов

796 Коммитов

Автор SHA1 Сообщение Дата
卜部昌平 1e8461424c rb_hash_transient_heap_evacuate: do not goto into a branch
I'm not necessarily against every goto in general, but jumping into a
branch is definitely a bad idea.  Better refactor.
2020-06-29 11:05:41 +09:00
卜部昌平 5f60538245 any_hash: do not goto into a branch
I'm not necessarily against every goto in general, but jumping into a
branch is definitely a bad idea.  Better refactor.
2020-06-29 11:05:41 +09:00
Timo Schilling 82ca8c7303
Add Hash#except ENV#except [Feature #15822] 2020-06-18 22:47:32 +09:00
Nobuyoshi Nakada 04fddf3573 ENV.delete should return the result of block on non-existing key
Fixes [Bug #16173]

Co-Authored-By: Burdette Lamar <burdettelamar@yahoo.com>
Co-Authored-By: Jeremy Evans <code@jeremyevans.net>
2020-06-10 12:49:27 -07:00
Burdette Lamar 8d4b259408
Enhanced Rdoc for Array#fetch and Array#index (#3202)
* Enhanced Rdoc for Array#fetch and Array#index
* Couple of tweaks (per review) in Rdoc for Hash
2020-06-10 06:45:29 -05:00
Burdette Lamar 7c2f742c40
Enhanced Rdoc for Hash (#3187)
Methods:

    #<=
    #<
    #>=
    #>
    #to_proc

Also, a small amount of housekeeping: Adding backslash to some class name to prevent linking.
2020-06-07 13:46:43 -05:00
Burdette Lamar e2d76478db
Enhanced Rdoc for Hash (#3178)
* Enhanced Rdoc for Hash

* Fix typo in Hash Rdoc

* Enhanced Rdoc for Hash
2020-06-03 18:53:56 -05:00
Burdette Lamar afefcade98
[ci skip] Enhanced Rdoc for Hash (#3162)
* Enhanced Rdoc for Hash

* Enhanced Rdoc for Hash
2020-06-02 10:53:25 -05:00
S-H-GAMELINKS 6a0405def2 fix typo in Hash#delete docs 2020-06-01 08:11:05 +09:00
Burdette Lamar c1f6552b58
[ci skip] Enhanced Rdoc for Hash (#3155)
* Enhanced Rdoc for Hash

* Respond to review
2020-05-29 13:53:11 -05:00
Burdette Lamar 28ce75821d
Enhanced Rdoc for Hash (#3151) 2020-05-28 06:21:48 -05:00
Burdette Lamar 139839b805
[ci skip] Enhanced Rdoc for Hash (#3143)
* Enhanced Rdoc for Hash

* Respond to review

* Nudge CI testing.
Respond to review
2020-05-27 09:31:22 -05:00
Burdette Lamar 8b8b7c7876
Enhanced Rdoc for Hash (#3139) 2020-05-23 20:35:05 -05:00
BurdetteLamar da484c3187 Enhanced Rdoc for Hash 2020-05-23 12:36:42 +12:00
Burdette Lamar ac395754c7
Enhanced rdoc for Hash (#3129) 2020-05-22 15:05:19 +12:00
S-H-GAMELINKS d707c92a35 add static modifier for rb_hash_keep_if func 2020-05-22 11:51:32 +09:00
S-H-GAMELINKS e5354de9f4 add static modifier for rb_hash_select_bang func 2020-05-22 11:51:32 +09:00
S-H-GAMELINKS 7c4e085938 add static modifier for rb_hash_select func 2020-05-22 11:51:32 +09:00
Burdette Lamar 140d4e4a5f
[ci skip] Enhanced rdoc for Hash (#3121) 2020-05-21 10:57:38 +12:00
S-H-GAMELINKS ff58cbce94 add static modifer for rb_hash_fetch_values func 2020-05-20 23:22:46 +09:00
Burdette Lamar d469807980
[CI skip] Enhance rdoc intro for Hash (#3056)
* Per @nobu review

* [CI skip] Enhance rdoc intro for Hash

* Tweak call-seq for Hash.new

* Tweak call-seq for Hash.new

* Minor corrections

* Respond to review

* Respond to review

* Respond to review

* Respond to review

* Fix chain exampmle

* Response to review
2020-05-15 14:11:42 -07:00
Jeremy Evans de29a022ac Document that #hash is not called for certain core classes [ci skip]
Fixes [Bug #16850]
2020-05-12 18:01:16 -07:00
卜部昌平 9e41a75255 sed -i 's|ruby/impl|ruby/internal|'
To fix build failures.
2020-05-11 09:24:08 +09:00
卜部昌平 d7f4d732c1 sed -i s|ruby/3|ruby/impl|g
This shall fix compile errors.
2020-05-11 09:24:08 +09:00
Nobuyoshi Nakada 5d430c1b34
Added more NORETURN declarations 2020-05-11 00:40:14 +09:00
Burdette Lamar f563f3c5ef
RDoc enhancements for Hash[]. 2020-04-23 20:46:20 +12:00
Nobuyoshi Nakada 0a986b81e1
Env values removed by ENV.clear are not used 2020-04-18 23:19:58 +09:00
Nobuyoshi Nakada 97e8c72e56
Bypass env key encoding conversion if unnecessary 2020-04-18 23:19:58 +09:00
Nobuyoshi Nakada ec4e57cae0
Hoisted out reset_by_modified_env 2020-04-18 23:19:58 +09:00
Nobuyoshi Nakada 08529a6115 Compare environment variable names in those manor [Bug #16798] 2020-04-18 23:09:01 +09:00
Burdette Lamar c28e230ab5
Improve Hash documentation. 2020-04-14 01:57:10 +12:00
卜部昌平 9e6e39c351
Merge pull request #2991 from shyouhei/ruby.h
Split ruby.h
2020-04-08 13:28:13 +09:00
Burdette Lamar 39c965f230
[ci skip] Doc-only enhancements for Hash
About the defalut values.
2020-03-27 12:33:39 +09:00
Jeremy Evans d2c41b1bff Reduce allocations for keyword argument hashes
Previously, passing a keyword splat to a method always allocated
a hash on the caller side, and accepting arbitrary keywords in
a method allocated a separate hash on the callee side.  Passing
explicit keywords to a method that accepted a keyword splat
did not allocate a hash on the caller side, but resulted in two
hashes allocated on the callee side.

This commit makes passing a single keyword splat to a method not
allocate a hash on the caller side.  Passing multiple keyword
splats or a mix of explicit keywords and a keyword splat still
generates a hash on the caller side.  On the callee side,
if arbitrary keywords are not accepted, it does not allocate a
hash.  If arbitrary keywords are accepted, it will allocate a
hash, but this commit uses a callinfo flag to indicate whether
the caller already allocated a hash, and if so, the callee can
use the passed hash without duplicating it.  So this commit
should make it so that a maximum of a single hash is allocated
during method calls.

To set the callinfo flag appropriately, method call argument
compilation checks if only a single keyword splat is given.
If only one keyword splat is given, the VM_CALL_KW_SPLAT_MUT
callinfo flag is not set, since in that case the keyword
splat is passed directly and not mutable.  If more than one
splat is used, a new hash needs to be generated on the caller
side, and in that case the callinfo flag is set, indicating
the keyword splat is mutable by the callee.

In compile_hash, used for both hash and keyword argument
compilation, if compiling keyword arguments and only a
single keyword splat is used, pass the argument directly.

On the caller side, in vm_args.c, the callinfo flag needs to
be recognized and handled.  Because the keyword splat
argument may not be a hash, it needs to be converted to a
hash first if not.  Then, unless the callinfo flag is set,
the hash needs to be duplicated.  The temporary copy of the
callinfo flag, kw_flag, is updated if a hash was duplicated,
to prevent the need to duplicate it again.  If we are
converting to a hash or duplicating a hash, we need to update
the argument array, which can including duplicating the
positional splat array if one was passed.  CALLER_SETUP_ARG
and a couple other places needs to be modified to handle
similar issues for other types of calls.

This includes fairly comprehensive tests for different ways
keywords are handled internally, checking that you get equal
results but that keyword splats on the caller side result in
distinct objects for keyword rest parameters.

Included are benchmarks for keyword argument calls.
Brief results when compiled without optimization:

  def kw(a: 1) a end
  def kws(**kw) kw end
  h = {a: 1}

  kw(a: 1)       # about same
  kw(**h)        # 2.37x faster
  kws(a: 1)      # 1.30x faster
  kws(**h)       # 2.19x faster
  kw(a: 1, **h)  # 1.03x slower
  kw(**h, **h)   # about same
  kws(a: 1, **h) # 1.16x faster
  kws(**h, **h)  # 1.14x faster
2020-03-17 12:09:43 -07:00
Yusuke Endoh 47141797be hash.c: Do not use the fast path (rb_yield_values) for lambda blocks
As a semantics, Hash#each yields a 2-element array (pairs of keys and
values).  So, `{ a: 1 }.each(&->(k, v) { })` should raise an exception
due to lambda's arity check.
However, the optimization that avoids Array allocation by using
rb_yield_values for blocks whose arity is more than 1 (introduced at
b9d2960337 and some commits), seemed to
overlook the lambda case, and wrongly allowed the code above to work.

This change experimentally attempts to make it strict; now the code
above raises an ArgumentError.  This is an incompatible change; if the
compatibility issue is bigger than our expectation, it may be reverted
(until Ruby 3.0 release).

[Bug #12706]
2020-03-16 23:17:12 +09:00
Alan Wu 713dc619f5 Add missing write barrier for Hash#transform_values{,!}
21994b7fd6 removed the write barrier that
was present in rb_hash_aset(). Re-insert it to not crash during GC.

[Bug #16689]
2020-03-15 18:11:52 -04:00
Koichi Sasada dff69bb462 Cast properly for shift operand
`(int) << RHASH_LEV_SHIFT` can be negative integer.
2020-03-09 02:53:46 +09:00
Koichi Sasada c3584dfacc check ar_table first.
RHASH_AR_TABLE_SIZE() has assertion that it is a ar_talbe.
The last commit breaks this assumption so check ar_table first.
2020-03-07 03:55:54 +09:00
Koichi Sasada 4c019f5a62 check ar_table after `#hash` call
ar_table can be converted to st_table just after `ar_do_hash()`
function which calls `#hash` method. We need to check
the representation to detect this mutation.
[Bug #16676]
2020-03-07 03:34:17 +09:00
卜部昌平 2325017477 fix compile error w/ -DUSE_TRANSIENT_HEAP=0
rb_transient_heap_managed_ptr_p is available only when USE_TRANSIENT_HEAP.
Need #if guards.
2020-03-04 12:30:42 +09:00
Marcus Stollsteimer 77dcc2c822 hash.c: [DOC] fix examples for ENV.merge! 2020-02-22 16:32:37 +01:00
Burdette Lamar af12e38675
More ENV rdoc [ci skip] 2020-02-22 10:25:54 +09:00
Nobuyoshi Nakada 036a68ae2c
[DOC] Fixed `ENV.rassoc` result order [ci skip] 2020-02-20 08:43:26 +09:00
Marcus Stollsteimer eed7235e33 hash.c: [DOC] fix typos 2020-02-19 20:59:21 +01:00
Nobuyoshi Nakada 125bcdb5cb
[DOC] use local variable like names [ci skip]
Use local variable like name as return value which is an instance
of that class but not constant itself.
2020-02-15 17:32:58 +09:00
Kazuhiro NISHIYAMA 36b7e95744
Fix typos and add a space [ci skip] 2020-02-14 14:26:19 +09:00
Burdette Lamar b9129dac21
Enhanced doc for ENV
* More on ENV examples
2020-02-14 14:18:48 +09:00
Burdette Lamar b7e0831e8f
Enhance rdoc for ENV 2020-02-09 15:59:55 +09:00
Tanaka Akira 338c5b8c1d Extract a function, ruby_reset_timezone().
Initial implementation of ruby_reset_timezone()
assigns ruby_tz_uptodate_p to false.
2020-01-28 23:40:25 +09:00
Nobuyoshi Nakada aefb13eb63
Added rb_warn_deprecated_to_remove
Warn the deprecation and future removal, with obeying the warning
flag.
2020-01-23 21:42:15 +09:00