diff options
author | Aaron Patterson <tenderlove@ruby-lang.org> | 2021-10-16 11:20:30 -0700 |
---|---|---|
committer | Nobuyoshi Nakada <nobu@ruby-lang.org> | 2021-10-18 17:41:38 +0900 |
commit | 57bf354c9a878bb67c294408400fd029f9b5a353 (patch) | |
tree | 036dca8fcd9066eee1e040d4b58ef9c570fde8bd /lib/thread.rb | |
parent | dfe944bfbed3cae47e3874de4ed0d2a96c047738 (diff) |
Eliminate some redundant checks on `num` in `newhash`
The `newhash` instruction was checking if `num` is greater than 0, but
so is [`rb_hash_new_with_size`](https://github.com/ruby/ruby/blob/82e2443d8b1e3edd2607c78dddf5aac79a13492d/hash.c#L1564)
as well as [`rb_hash_bulk_insert`](https://github.com/ruby/ruby/blob/82e2443d8b1e3edd2607c78dddf5aac79a13492d/hash.c#L4764).
If we know the size is 0 in the instruction, we can just directly call
`rb_hash_new` and only check the size once. Unfortunately, when num is
greater than 0, it's still checked 3 times.
Notes
Notes:
Merged: https://github.com/ruby/ruby/pull/4977
Diffstat (limited to 'lib/thread.rb')
0 files changed, 0 insertions, 0 deletions