Skip to content

Remove method_missing usage in Idv::Session#11857

Merged
zachmargolis merged 2 commits intomainfrom
margolis-remove-method-missing
Feb 7, 2025
Merged

Remove method_missing usage in Idv::Session#11857
zachmargolis merged 2 commits intomainfrom
margolis-remove-method-missing

Conversation

@zachmargolis
Copy link
Contributor

  • Per comment on #11854, the dynamic access and string manipulation makes these methods a hotspot

  • Dynamically defining these methods one should hopefully let the JIT optimize this a little better, and lets us use the default implementations for #method_missing and #respond_to_missing?

NB, I have not performance tested this myself to confirm the hypothesis, I am open to checking that before merging. The unit test coverage is solid so this should still work

- Per comment on #11854, the dynamic access and string manipulation
  makes these methods a hotspot

- Dynamically defining these methods one should hopefully let the
  JIT optimize this a little better, and lets us use the default
  implementations for #method_missing and #respond_to_missing?

changelog: Internal, Source code, Optimize dynamic method access
@zachmargolis zachmargolis requested a review from a team February 7, 2025 19:59
it 'allows supported attributes' do
it 'allows using supported setters and getters' do
Idv::Session::VALID_SESSION_ATTRIBUTES.each do |attr|
subject.send attr, 'foo'
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So before calling idv_session.address_edited('foo') would act as a setter.

That is very uncommon! I made a call to remove that, now it will throw an argument error because now reader and writer are two separate methods.

Open to changing this back if we are worried, but I expect our test suite would catch any lingering use of that style

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I noticed this too, glad to see a fix

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed two sneaky-setter usages in f2426a2

@zachmargolis zachmargolis merged commit f11a1e6 into main Feb 7, 2025
@zachmargolis zachmargolis deleted the margolis-remove-method-missing branch February 7, 2025 20:34
Copy link
Contributor

@mitchellhenke mitchellhenke left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is really incredible, glad to see some much simpler refactoring of the less than common patterns used previously!

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.

3 participants