Skip to content

Commit

Permalink
Merge pull request #69 from teknologi-umum/perf/empty
Browse files Browse the repository at this point in the history
  • Loading branch information
aldy505 authored Nov 28, 2021
2 parents f9a9b63 + 834ae8d commit cbce1bd
Show file tree
Hide file tree
Showing 2 changed files with 125 additions and 127 deletions.
22 changes: 10 additions & 12 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,25 +87,23 @@ function flourite(
for (let i = 0; i < pairs.length; i++) {
const { language, checkers } = pairs[i];

const pointsList: number[] = [];
let points = 0;
for (let j = 0; j < linesOfCode.length; j++) {
// fast return if the current line of code is empty or contains only spaces
if (/^\s*$/.test(linesOfCode[j])) {
continue;
}

if (!nearTop(j, linesOfCode)) {
pointsList.push(
getPoints(
linesOfCode[j],
checkers.filter((checker) => !checker.nearTop),
),
points += getPoints(
linesOfCode[j],
checkers.filter((checker) => !checker.nearTop),
);
} else {
pointsList.push(getPoints(linesOfCode[j], checkers));
points += getPoints(linesOfCode[j], checkers);
}
}

let points = 0;
for (let k = 0; k < pointsList.length; k++) {
points += pointsList[k];
}

results.push({ language, points });
}

Expand Down
Loading

0 comments on commit cbce1bd

Please sign in to comment.