Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Optimization to bind define_method with unbound method directly.
Before this change, we would rebind the method passed to Module# define_method every invocation. However, since the only requirement for define_method against a method or unbound method is that the rebind would succeed (by having the method in the same hierarchy), rebinding for every object is unnecessary. This optimization removes that rebinding and just transplant the method from the source to the original DynamicMethod. Invocations of the name bound by define_method then perform exactly as the original. This could be more useful if the UnboundMethod could come from any module, since modules can in theory live in any hierarchy. Libraries of utility methods could be assembled via define_method into other classes. I may explore that as a feature to present to the other implementers.
- Loading branch information