rmosolgo / graphql-ruby

Ruby implementation of GraphQL
http://graphql-ruby.org
MIT License
5.37k stars 1.39k forks source link

PoC: Optimize predicate methods with `attr_reader` #5082

Open amomchilov opened 4 weeks ago

amomchilov commented 4 weeks ago

PoC for #5081

rmosolgo commented 4 weeks ago

Hey, thanks for proposing this change! I'm definitely interested in it. Another implementation might be write a Rubocop rule which identifies and updates code that uses the "bad" approach. There are a couple other development-related cops here in case you're interested in try that: https://github.com/rmosolgo/graphql-ruby/tree/master/cop/development

amomchilov commented 4 weeks ago

@rmosolgo Happy to hear! This is definitely rubocop-able. I'd even go so far as to add it upstream to https://github.com/rubocop/rubocop-performance

Would you mind running a quick benchmark on this, to see if it's worthwhile? Btw I wrote up more details in the issue: #5081

I have some env issues, and I won't have time to sort them out until at least next week