Skip to content

Commit 6ca53c8

Browse files
committed
a little more special casing in CFGExtractor union
1 parent 7e422a6 commit 6ca53c8

File tree

1 file changed

+7
-10
lines changed

1 file changed

+7
-10
lines changed

javascript/extractor/src/com/semmle/js/extractor/CFGExtractor.java

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,9 @@ private static Collection<Node> union(Collection<Node> xs, Node y) {
212212
return xs;
213213
}
214214

215-
return nonNullUnion(xs, Collections.singleton(y));
215+
List<Node> result = new ArrayList<>(xs);
216+
result.add(y);
217+
return result;
216218
}
217219

218220
private static Collection<Node> union(Node x, Collection<Node> ys) {
@@ -226,7 +228,10 @@ private static Collection<Node> union(Node x, Collection<Node> ys) {
226228
return ys;
227229
}
228230

229-
return nonNullUnion(Collections.singleton(x), ys);
231+
List<Node> result = new ArrayList<>();
232+
result.add(x);
233+
result.addAll(ys);
234+
return result;
230235
}
231236

232237
/**
@@ -240,14 +245,6 @@ private static Collection<Node> union(Collection<Node> xs, Collection<Node> ys)
240245
return xs;
241246
}
242247

243-
return nonNullUnion(xs, ys);
244-
}
245-
246-
/**
247-
* Creates an order preserving concatenation of the nodes in `xs` and `ys` without duplicates.
248-
* Where `xs` and `ys` have non null values, and are non-empty.
249-
*/
250-
private static Collection<Node> nonNullUnion(Collection<Node> xs, Collection<Node> ys) {
251248
List<Node> result = new ArrayList<>(xs);
252249
for (Node y : ys) {
253250
if (!result.contains(y)) {

0 commit comments

Comments
 (0)