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

Tiny refactor of method_missing definition #3660

Merged
merged 1 commit into from
Dec 13, 2016
Merged

Tiny refactor of method_missing definition #3660

merged 1 commit into from
Dec 13, 2016

Conversation

splattael
Copy link
Contributor

@splattael splattael commented Dec 9, 2016

  • Removed unused var args_node
  • Handle named_args_nodes similar to args_nodes
  • Drop try for non-nil named_args

@splattael
Copy link
Contributor Author

Refs 8295d8c

@@ -38,7 +38,7 @@ module Crystal
def define_method_from_method_missing(method_missing, signature, original_call)
name_node = StringLiteral.new(signature.name)
args_nodes = [] of ASTNode
named_args_nodes = nil
named_args_nodes = [] of NamedArgument
Copy link
Member

Choose a reason for hiding this comment

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

But this will allocate an array all the time, even if not used...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@asterite Oh, that's true. I wanted to stay "symmetrical" with args_nodes.
I wonder, is allocating an array a hotspot here?

Anyway, I could revert the change for named_args_nodes. How about the other changes? Should I close this PR?

Copy link
Member

Choose a reason for hiding this comment

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

I usually don't care about hotspots, if I can easily avoid an allocation, I do it.

The other changes look good, though :-)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@asterite I've reverted to named_args_nodes = nil. The other changes remained.

👀 ?

* Removed unused var `args_node`
* Drop `try` for non-nil `named_args`
@asterite asterite merged commit 278ffff into crystal-lang:master Dec 13, 2016
@splattael
Copy link
Contributor Author

Thanks for merging! 💜

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.

2 participants