Skip to content

Commit 014728a

Browse files
committed
implement hcaerof in terms of foreach
1 parent ca26b5e commit 014728a

File tree

1 file changed

+4
-9
lines changed

1 file changed

+4
-9
lines changed

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

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -189,15 +189,10 @@ private static Iterable<Node> foreach(Object nd) {
189189
}
190190

191191
private Iterable<Node> hcaerof(final Object nd) {
192-
if (nd == null) return Collections.<Node>emptySet();
193-
if (nd instanceof Node) return CollectionUtil.singletonIterable((Node) nd);
194-
return new Iterable<Node>() {
195-
@SuppressWarnings("unchecked")
196-
@Override
197-
public Iterator<Node> iterator() {
198-
return CollectionUtil.reverseIterator((List<Node>) nd);
199-
}
200-
};
192+
List<Node> list = new ArrayList<>();
193+
foreach(nd).forEach(list::add);
194+
Collections.reverse(list);
195+
return list;
201196
}
202197

203198
/** Returns a list of all the nodes in a tree of nested lists. */

0 commit comments

Comments
 (0)