Skip to content

Commit 537d3c9

Browse files
committed
small optimization
1 parent 515482e commit 537d3c9

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

src/main/java/org/htmlunit/cyberneko/HTMLTagBalancer.java

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -196,10 +196,10 @@ public class HTMLTagBalancer
196196
// state
197197

198198
/** The element stack. */
199-
protected final InfoStack fElementStack = new InfoStack();
199+
protected final InfoStack fElementStack = new InfoStack(20);
200200

201201
/** The inline stack. */
202-
protected final InfoStack fFormattingStack = new InfoStack();
202+
protected final InfoStack fFormattingStack = new InfoStack(10);
203203

204204
/** True if seen anything. Important for xml declaration. */
205205
protected boolean fSeenAnything;
@@ -267,8 +267,8 @@ public class HTMLTagBalancer
267267
private QName[] fragmentContextStack_ = null;
268268
private int fragmentContextStackSize_ = 0; // not 0 only when a fragment is parsed and fragmentContextStack_ is set
269269

270-
private final List<ElementEntry> endElementsBuffer_ = new ArrayList<>();
271-
private final List<String> discardedStartElements = new ArrayList<>();
270+
private final List<ElementEntry> endElementsBuffer_ = new ArrayList<>(4);
271+
private final List<String> discardedStartElements = new ArrayList<>(2);
272272

273273
private final HTMLConfiguration htmlConfiguration_;
274274

@@ -1508,7 +1508,11 @@ public static class InfoStack {
15081508
public int top;
15091509

15101510
/** The stack data. */
1511-
public Info[] data = new Info[10];
1511+
public Info[] data;
1512+
1513+
public InfoStack(final int initialSize) {
1514+
data = new Info[initialSize];
1515+
}
15121516

15131517
// Pushes element information onto the stack.
15141518
public void push(final Info info) {

0 commit comments

Comments
 (0)