Skip to content

Commit

Permalink
#98 aibolit nested loop fixed in XpathDirective
Browse files Browse the repository at this point in the history
  • Loading branch information
yegor256 committed Jul 13, 2020
1 parent 75f177e commit f86100e
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions src/main/java/org/xembly/XpathDirective.java
Original file line number Diff line number Diff line change
Expand Up @@ -152,14 +152,24 @@ private static Collection<Node> traditional(final String query,
String.format("invalid XPath expr '%s'", query), ex
);
}
final int len = list.getLength();
for (int idx = 0; idx < len; ++idx) {
targets.add(list.item(idx));
}
XpathDirective.copyTo(list, targets);
}
return targets;
}

/**
* Copy nodes from NodeList to a collection.
* @param list The list
* @param targets Collection
*/
private static void copyTo(final NodeList list,
final Collection<Node> targets) {
final int len = list.getLength();
for (int idx = 0; idx < len; ++idx) {
targets.add(list.item(idx));
}
}

/**
* Get roots to start searching from.
* @param dom Document
Expand Down

0 comments on commit f86100e

Please sign in to comment.