Optimization: Unneeded collection creation eliminated

This commit is contained in:
Andrey Breslav
2013-04-16 17:12:40 +04:00
parent da2d417662
commit a514d76116
@@ -102,20 +102,18 @@ import static org.jetbrains.jet.lang.resolve.calls.ValueArgumentsToParametersMap
// We saw only positioned arguments so far // We saw only positioned arguments so far
private final ProcessorState positionedOnly = new ProcessorState() { private final ProcessorState positionedOnly = new ProcessorState() {
private Queue<ValueParameterDescriptor> valueParameterQueue; private int currentParameter = 0;
@Nullable @Nullable
public ValueParameterDescriptor nextValueParameter() { public ValueParameterDescriptor nextValueParameter() {
if (valueParameterQueue == null) { List<ValueParameterDescriptor> parameters = candidateCall.getCandidateDescriptor().getValueParameters();
valueParameterQueue = new LinkedList<ValueParameterDescriptor>(candidateCall.getCandidateDescriptor().getValueParameters()); if (currentParameter >= parameters.size()) return null;
}
ValueParameterDescriptor head = valueParameterQueue.peek(); ValueParameterDescriptor head = parameters.get(currentParameter);
if (head == null) return null;
// If we found a vararg parameter, we are stuck with it forever // If we found a vararg parameter, we are stuck with it forever
if (head.getVarargElementType() == null) { if (head.getVarargElementType() == null) {
valueParameterQueue.remove(); currentParameter++;
} }
return head; return head;