Add DynamicProxyObject to fix time-consuming "getter"-methods#112
Open
wuarmin wants to merge 4 commits intofotinakis:masterfrom
Open
Add DynamicProxyObject to fix time-consuming "getter"-methods#112wuarmin wants to merge 4 commits intofotinakis:masterfrom
wuarmin wants to merge 4 commits intofotinakis:masterfrom
Conversation
|
|
||
| def method_missing(name, *args, &block) | ||
| key = cache_key(name, args) | ||
| @cache[key] ||= @target.send(name, *args, &block) |
There was a problem hiding this comment.
This should be public_send, for maximum clarity.
There was a problem hiding this comment.
I don't think ||= will be a good enough check. Different args or a block should produce different results.
| def method_missing(name, *args, &block) | ||
| key = cache_key(name, args) | ||
| @cache[key] ||= @target.send(name, *args, &block) | ||
| @cache[key] |
There was a problem hiding this comment.
This line can be deleted. All ruby ...=... syntax always returns the right most expression.
| return nil unless objects | ||
| if objects.respond_to?(:map) | ||
| objects.map { |obj| DynamicProxyObject.new(obj) } | ||
| else |
There was a problem hiding this comment.
IMO respond_to?(:map) is too weak of a trait check. Any object could have the method map and not be a collection.
Author
|
@krainboltgreene thank you for your review. I'll address your proposals. |
|
@wuarmin FWIW I don't envy your task! Cache-level optimizations are hard and can be unpredictable at the library level. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Hello ;)
What is your opinion on my proposal?
It solves huge performance issues for us, because we are dealing with objects with slow and unchangeable getter-methods.
We had a conversation at #99.
Thank you for your feedback.