Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mock: simplify implementation of FunctionalOptions #1571

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

dolmen
Copy link
Collaborator

@dolmen dolmen commented Mar 7, 2024

Summary

Remove unnecessary use of reflect in the implementation of mock.FunctionalOptions().

Changes

  • Change the internal representation of FunctionalOptionsArgument to be a slice of arguments to match the variadic argument of FunctionalOptions.
  • Remove unnecessary use of reflect.

Motivation

  • Simpler code
  • Runtime speed

@dolmen dolmen added pkg-mock Any issues related to Mock internal/refactor Refactor internals with no external visible changes mock.ArgumentMatcher About matching arguments in mock labels Mar 7, 2024
@dolmen dolmen self-assigned this Mar 7, 2024
@dolmen
Copy link
Collaborator Author

dolmen commented Mar 22, 2024

@snirye Could you review this change as you are a mock.FunctionalOptions user?

@dolmen
Copy link
Collaborator Author

dolmen commented Mar 22, 2024

@nbaztec Could you review this change as you wrote the initial implementation?

brackendawson
brackendawson previously approved these changes Apr 1, 2024
Copy link
Collaborator

@brackendawson brackendawson left a comment

Choose a reason for hiding this comment

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

LGTM

I did some testing. No behavioural change but less uncecessary reflection.

Remove unnecessary use of reflect in the implementation of
mock.FunctionalOptions().
@dolmen
Copy link
Collaborator Author

dolmen commented Apr 23, 2024

Rebased (with conflict resolution) after merge of f1b5324 (#1433).

Copy link
Collaborator

@brackendawson brackendawson left a comment

Choose a reason for hiding this comment

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

Still LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
internal/refactor Refactor internals with no external visible changes mock.ArgumentMatcher About matching arguments in mock pkg-mock Any issues related to Mock
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants