Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@headius
Copy link
Member

@headius headius commented Oct 24, 2023

The basic idea here is to avoid pushing a frame for block_given? when it is known to be our core implementation. Instead, we use indy to test the block the current method was called with and return a result directly. When the block_given? is not our core impl, it falls back on a normal indy invocation. This allows us to remove the frame requirement from block_given? callers, and the cost of the block_given? call largely disappears.

Caveats:

  • This is very much hacked in place, with duplicated code in multiple places.
  • In order to pass through the block we were given, we add a Block parameter to the call site. If someone defines a block_given? in Ruby, it would receive our given block.

The basic idea here is to avoid pushing a frame for block_given?
when it is known to be our core implementation. Instead, we use
indy to test the block the current method was called with and
return a result directly. When the block_given? is not our
core impl, it falls back on a normal indy invocation. This allows
us to remove the frame requirement from block_given? callers, and
the cost of the block_given? call largely disappears.

Caveats:

* This is very much hacked in place, with duplicated code in
  multiple places.
* In order to pass through the block we were given, we add a Block
  parameter to the call site. If someone defines a block_given?
  in Ruby, it would receive our given block.
@headius
Copy link
Member Author

headius commented Mar 27, 2024

Superseded by #8170.

@headius headius closed this Mar 27, 2024
@headius headius added this to the Invalid or Duplicate milestone Mar 27, 2024
@headius headius deleted the fast_block_given branch March 27, 2024 20:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant