return varlen;
}
private static final int THRESHOLD_CASE_FOLD_ALT_FOR_EXPANSION = 8;
private Node expandCaseFoldString(Node node) {
StringNode sn = (StringNode)node;
if (sn.isAmbig() || sn.length() <= 0) return node;
byte[]bytes = sn.bytes;
int p = sn.p;
int end = sn.end;
int altNum = 1;
ConsAltNode topRoot = null, root = null;
ObjPtr<Node> prevNode = new ObjPtr<Node>();
StringNode stringNode = null;
while (p < end) {
CaseFoldCodeItem[]items = enc.caseFoldCodesByString(regex.caseFoldFlag, bytes, p, end);
int len = enc.length(bytes, p, end);
if (items.length == 0) {
if (stringNode == null) {
if (root == null && prevNode.p != null) {
topRoot = root = ConsAltNode.listAdd(null, prevNode.p);
}
prevNode.p = stringNode = new StringNode(); // onig_node_new_str(NULL, NULL);
if (root != null) ConsAltNode.listAdd(root, stringNode);
}
stringNode.cat(bytes, p, p + len);
} else {
altNum *= (items.length + 1);
if (altNum > THRESHOLD_CASE_FOLD_ALT_FOR_EXPANSION) break;
if (root == null && prevNode.p != null) {