-
Notifications
You must be signed in to change notification settings - Fork 33
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
refactor DefaultFunctionCallExpr #168
base: master
Are you sure you want to change the base?
refactor DefaultFunctionCallExpr #168
Conversation
@@ -77,7 +77,7 @@ public void addParameter(Expr parameter) | |||
} | |||
|
|||
|
|||
public List getParameters() | |||
public List<Expr> getParameters() |
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.
This is a potentially code breaking public API change, which we won't do. (Consider subclasses that override this method.) Ditto for other signature changes below.
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 have done a little test.
I have written an class OverwriteTest like so:
package org.jaxen.expr;
import java.util.List;
public class OverwriteTest extends DefaultFunctionCallExpr {
public OverwriteTest(String prefix, String functionName) {
super(prefix, functionName);
}
@Override
public List getParameters() {
return super.getParameters();
}
}
No Problem for the Java Compiler. Indeed it is not a good practice to drop the generics, but it is possible without an API break.
If you agree the signature in the interface FunctionCallExpr
should also be changed.
|
||
paramValues.add(eachValue); | ||
for (Expr eachParam : paramExprs) { |
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.
foreach might be clearer. There's no proof it's faster.
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.
You are right. This is possibly a flawed assumption on my part, but still it's also not slower. The compiler should optimize both to the same speed.
I made the fields
prefix
andfunctionName
final.Gentrified all lists and replaced the for loop by the foreach loop (available size Java 5).
The foreach loop is easier to read and faster, compared to the normal for loop.