Skip to content

Commit 78be89a

Browse files
committed
Move iter into Has class
#2088
1 parent 374ded2 commit 78be89a

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

src/main/java/org/jsoup/select/StructuralEvaluator.java

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -58,19 +58,18 @@ public boolean matches(Element root, Element element) {
5858
}
5959
}
6060

61-
final ThreadLocal<NodeIterator<Element>> threadHasIter =
62-
ThreadLocal.withInitial(() -> new NodeIterator<>(new Element("html"), Element.class));
63-
// the element here is just a placeholder so this can be final - gets set in restart()
64-
6561
static class Has extends StructuralEvaluator {
62+
static final ThreadLocal<NodeIterator<Element>> ThreadElementIter =
63+
ThreadLocal.withInitial(() -> new NodeIterator<>(new Element("html"), Element.class));
64+
// the element here is just a placeholder so this can be final - gets set in restart()
6665

6766
public Has(Evaluator evaluator) {
6867
super(evaluator);
6968
}
7069

7170
@Override public boolean matches(Element root, Element element) {
7271
// for :has, we only want to match children (or below), not the input element. And we want to minimize GCs
73-
NodeIterator<Element> it = threadHasIter.get();
72+
NodeIterator<Element> it = ThreadElementIter.get();
7473

7574
it.restart(element);
7675
while (it.hasNext()) {

0 commit comments

Comments
 (0)