Skip to content

Commit

Permalink
Do not run same loop again
Browse files Browse the repository at this point in the history
  • Loading branch information
Arturas Moskvinas committed Nov 8, 2017
1 parent 8fc0ff7 commit 8a2362c
Showing 1 changed file with 6 additions and 10 deletions.
Expand Up @@ -120,6 +120,7 @@ private Map<String, List<Integer>> parse(Map<NodeList, List<String>> coverageDat

// Collect all filenames in coverage report
List<String> fileNames = new ArrayList<String>();
List<NodeList> childNodes = new ArrayList<NodeList>();
for (int i = 0; i < classes.getLength(); i++) {
Node classNode = classes.item(i);
String fileName = classNode.getAttributes().getNamedItem(NODE_FILENAME).getTextContent();
Expand All @@ -128,28 +129,23 @@ private Map<String, List<Integer>> parse(Map<NodeList, List<String>> coverageDat
continue;
}
fileNames.add(fileName);
childNodes.add(classNode.getChildNodes());
}

// Make multiple guesses on which of the `sourceDirs` contains files in question
Map<String, String> detectedSourceRoots = new PathResolver(workspace, sourceDirs).choose(fileNames);

// Loop over all files in the coverage report
for (int i = 0; i < classes.getLength(); i++) {
Node classNode = classes.item(i);
String fileName = classNode.getAttributes().getNamedItem(NODE_FILENAME).getTextContent();

if (includeFileNames != null && !includeFileNames.contains(FilenameUtils.getName(fileName))) {
continue;
}

// Loop over all files which are needed for coverage report
for (int i = 0; i < fileNames.size(); i++) {
String fileName = fileNames.get(i);
fileName = join(detectedSourceRoots.get(fileName), fileName);

SortedMap<Integer, Integer> hitCounts = internalCounts.get(fileName);
if (hitCounts == null) {
hitCounts = new TreeMap<Integer, Integer>();
}

NodeList children = classNode.getChildNodes();
NodeList children = childNodes.get(i);
for (int j = 0; j < children.getLength(); j++) {
Node child = children.item(j);

Expand Down

0 comments on commit 8a2362c

Please sign in to comment.