Skip to content

Commit

Permalink
Showing 1 changed file with 4 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -68,6 +68,10 @@ public boolean isBlock() {
}

public ArgumentDescriptor[] getArgumentDescriptors() {
if (argumentDescriptors == null) {
return new ArgumentDescriptor[] {};
}

return Arrays.copyOf(argumentDescriptors, argumentDescriptors.length);
}

3 comments on commit 5446cc2

@nirvdrum
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@eregon @chrisseaton I don't know if storing null originally was done as a memory/allocation saving feature. If not, I can change the code to store the empty array in the SharedMethodInfo constructor and remove this conditional.

An example failure case was:

p Class.new { attr_writer :foo }.instance_method(:foo=).parameters

RSpec does this during its startup for some reason.

@chrisseaton
Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah simpler is better - allocation the array in the constructor.

@nirvdrum
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Revised in 3cc7f86.

Please sign in to comment.