Skip to content

Commit

Permalink
refactor(MissingBlobs): Track missing dependencies using a Set
Browse files Browse the repository at this point in the history
The missingBlobs Map object's value was never used and always
remained null. Switching to a Set improves clarity.
  • Loading branch information
joshchoo committed Jan 26, 2019
1 parent a329ef3 commit 6a88b08
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions src/MissingBlobs.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;

public class MissingBlobs {

Expand All @@ -20,10 +22,9 @@ public class MissingBlobs {
private HashMap<String, ArrayList<Blob>> dependencyBlobs;

/*
* Key: Name of missing blob dependency
* Value: Null (unused)
* Value: Name of missing blob dependency
*/
private HashMap<String, String> missingBlobs;
private Set<String> missingBlobs;

private String expandArrayList(ArrayList<Blob> arr) {
StringBuilder expanded = new StringBuilder();
Expand Down Expand Up @@ -103,21 +104,20 @@ public void addBlobDir(String blobPath) {
}

public void updateMissingBlobs() {
missingBlobs = new HashMap<String, String>();
missingBlobs = new HashSet<String>();

for (Map.Entry<String, ArrayList<Blob>> blob : dependencyBlobs.entrySet()) {
String dependencyName = blob.getKey();

if (missingBlobs.containsKey(dependencyName) || presentBlobs.containsKey(dependencyName))
if (missingBlobs.contains(dependencyName) || presentBlobs.containsKey(dependencyName))
continue;

missingBlobs.put(dependencyName, null);
missingBlobs.add(dependencyName);
}
}

public void showMissingBlobs() {
for (Map.Entry<String, String> blob : missingBlobs.entrySet()) {
String dependencyName = blob.getKey();
for (String dependencyName : missingBlobs) {
ArrayList<Blob> blobsWithDependencies = dependencyBlobs.get(dependencyName);
System.out.println(dependencyName + " required by: " + expandArrayList(blobsWithDependencies));
}
Expand Down

0 comments on commit 6a88b08

Please sign in to comment.