Skip to content

Commit

Permalink
Remove java stream usages
Browse files Browse the repository at this point in the history
  • Loading branch information
Nadeeshan96 committed Aug 15, 2023
1 parent 595e61f commit c00df1f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -270,8 +270,11 @@ private static String emitInsNewArray(BIRNonTerminator.NewArray ins, int tabs) {
}

private static String emitArrayValues(List<BIRNode.BIRListConstructorEntry> values) {
BIROperand[] valueOperands = values.stream().map(x -> x.exprOp).limit(INITIAL_VALUE_COUNT)
.toArray(BIROperand[]::new);
int operandArraySize = Math.min(INITIAL_VALUE_COUNT, values.size());
BIROperand[] valueOperands = new BIROperand[operandArraySize];
for (int i = 0; i < operandArraySize; i++) {
valueOperands[i] = values.get(i).exprOp;
}
String result = emitVarRefs(valueOperands);
return values.size() > INITIAL_VALUE_COUNT ? result + ",..." : result;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -242,17 +242,18 @@ private static String getClassName(String balFileName) {
if (!balFileName.endsWith(".bal")) {
return balFileName;
}

return balFileName.substring(0, balFileName.length() - 4);
}

private static BIRNode.BIRFunction getInvokedFunction(CompileResult compileResult, String functionName) {
checkAndNotifyCompilationErrors(compileResult);
BIRNode.BIRPackage birPackage = compileResult.defaultModuleBIR();
return birPackage.functions.stream()
.filter(function -> functionName.equals(function.name.value))
.findFirst()
.orElseThrow(() -> new RuntimeException("Function '" + functionName + "' is not defined"));
for (BIRNode.BIRFunction function : birPackage.functions) {
if (functionName.equals(function.name.value)) {
return function;
}
}
throw new RuntimeException("Function '" + functionName + "' is not defined");
}

private static void checkAndNotifyCompilationErrors(CompileResult compileResult) {
Expand Down

0 comments on commit c00df1f

Please sign in to comment.