Skip to content

Commit 6a88b08

Browse files
committed
refactor(MissingBlobs): Track missing dependencies using a Set
The missingBlobs Map object's value was never used and always remained null. Switching to a Set improves clarity.
1 parent a329ef3 commit 6a88b08

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

src/MissingBlobs.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@
33
import java.io.InputStreamReader;
44
import java.util.ArrayList;
55
import java.util.HashMap;
6+
import java.util.HashSet;
67
import java.util.Map;
8+
import java.util.Set;
79

810
public class MissingBlobs {
911

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

2224
/*
23-
* Key: Name of missing blob dependency
24-
* Value: Null (unused)
25+
* Value: Name of missing blob dependency
2526
*/
26-
private HashMap<String, String> missingBlobs;
27+
private Set<String> missingBlobs;
2728

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

105106
public void updateMissingBlobs() {
106-
missingBlobs = new HashMap<String, String>();
107+
missingBlobs = new HashSet<String>();
107108

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

111-
if (missingBlobs.containsKey(dependencyName) || presentBlobs.containsKey(dependencyName))
112+
if (missingBlobs.contains(dependencyName) || presentBlobs.containsKey(dependencyName))
112113
continue;
113114

114-
missingBlobs.put(dependencyName, null);
115+
missingBlobs.add(dependencyName);
115116
}
116117
}
117118

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

0 commit comments

Comments
 (0)