Skip to content

Commit

Permalink
Use ArrayDeque instead of Stack (#349)
Browse files Browse the repository at this point in the history
  • Loading branch information
tushuhei authored Oct 30, 2023
1 parent 651fd4e commit edbdc7d
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions java/src/main/java/com/google/budoux/HTMLProcessor.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@
import java.io.InputStreamReader;
import java.io.Reader;
import java.nio.charset.StandardCharsets;
import java.util.ArrayDeque;
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import java.util.Locale;
import java.util.Set;
import java.util.Stack;
import java.util.stream.Collectors;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
Expand Down Expand Up @@ -63,7 +63,7 @@ private static class PhraseResolvingNodeVisitor implements NodeVisitor {
private final StringBuilder output = new StringBuilder();
private Integer scanIndex = 0;
private boolean toSkip = false;
private Stack<Boolean> elementStack = new Stack<Boolean>();
private final ArrayDeque<Boolean> elementStack = new ArrayDeque<>();

/**
* Constructs a PhraseResolvingNodeVisitor.
Expand Down Expand Up @@ -126,7 +126,7 @@ public void tail(Node node, int depth) {
if (node.nodeName().equals("body") || node instanceof TextNode) {
return;
}
assert node instanceof Element;
// assume node instanceof Element;
toSkip = elementStack.pop();
output.append(String.format("</%s>", node.nodeName()));
}
Expand Down

0 comments on commit edbdc7d

Please sign in to comment.