< prev index next >
src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/regexp/joni/ast/StringNode.java
Print this page
rev 52890 : 8223904: Improve Nashorn matching
Reviewed-by: jlaskey, sundar, mschoene, rhalade
*** 25,44 ****
@SuppressWarnings("javadoc")
public final class StringNode extends Node implements StringType {
private static final int NODE_STR_MARGIN = 16;
private static final int NODE_STR_BUF_SIZE = 24;
- public static final StringNode EMPTY = new StringNode(null, Integer.MAX_VALUE, Integer.MAX_VALUE);
public char[] chars;
public int p;
public int end;
public int flag;
public StringNode() {
! this.chars = new char[NODE_STR_BUF_SIZE];
}
public StringNode(final char[] chars, final int p, final int end) {
this.chars = chars;
this.p = p;
--- 25,49 ----
@SuppressWarnings("javadoc")
public final class StringNode extends Node implements StringType {
private static final int NODE_STR_MARGIN = 16;
private static final int NODE_STR_BUF_SIZE = 24;
public char[] chars;
public int p;
public int end;
public int flag;
public StringNode() {
! this(NODE_STR_BUF_SIZE);
! }
!
! private StringNode(int size) {
! this.chars = new char[size];
! this.p = 0;
! this.end = 0;
}
public StringNode(final char[] chars, final int p, final int end) {
this.chars = chars;
this.p = p;
*** 49,58 ****
--- 54,70 ----
public StringNode(final char c) {
this();
chars[end++] = c;
}
+ /**
+ * Create a new empty StringNode.
+ */
+ public static StringNode createEmpty() {
+ return new StringNode(0);
+ }
+
/* Ensure there is ahead bytes available in node's buffer
* (assumes that the node is not shared)
*/
public void ensure(final int ahead) {
final int len = (end - p) + ahead;
< prev index next >