-
-
Notifications
You must be signed in to change notification settings - Fork 55
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
Fix and optimize arguments handling #72
Conversation
a0e6a6f
to
6b80481
Compare
# Same functionality as ParameterizedNode, but optimized for Nodes | ||
# where `arguments` are `children[first_argument_index..-1]` | ||
# | ||
module ParameterizedTrailNode |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't quite get the "trail" terminology.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The first few children are not the arguments, only the trailing ones are.
I don't like ParameterizedNode
, and I dislike ParameterizedTrailNode
even more 😅, but I'm severly uninspired. Suggestions?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@bbatsov is TrailingArgumentsNode
a better name?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ping @bbatsov
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It gets a bit hairy, I guess, because the naming of the other nodes make reference to Ruby and its syntax, while this is a reference to the Parser output.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Drenmi right, but there is still shared handling of the AST like in WrappedArgumentsNode
(that isn't just an optimization)
One way would be to have ParameterizedNode::SingleChildArguments
/ ParameterizedNode::LastChildrenArguments
and ParameterizedNode::WrappedArguments
or similar, to denote the 3 different ways Parser
encodes arguments?
This could even be handled automatically by ParameterizedNode
when there's a def first_argument_index
or similar that is encountered, but it feels too much.
I've refactored this a bit to improve the naming. Relevant nodes can still I'd like to merge this if it sounds ok and cut a release of |
…for argument processing
No longer define `parameters` in `MethodDispatchNode`
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like the current version.
When looking at some cops' performance I realized that
#arguments?
seemed to take non-negligible time. I realized that it creates an array, only to later check if it's empty. This PR optimizes this, forSendNode
and others like it (modern mode only).SuperNode
,DefinedNode
andYieldNode
were worse, in that two temporary arrays were created for each argument call (including#arguments?
) and are also (trivially) optimized.This fixes
LambdaNode
(modern only) for arguments and#receiver