문제

The source code of constructor of Matcher class:

Matcher(Pattern parent, CharSequence text) {
    this.parentPattern = parent;
    this.text = text;

    // Allocate state storage
    int parentGroupCount = Math.max(parent.capturingGroupCount, 10);
    groups = new int[parentGroupCount * 2];
    locals = new int[parent.localCount];

    // Put fields into initial states
    reset();
}

Why we don't just use parent.capturingGroupCount*2 as the length of groups?

도움이 되었습니까?

해결책

It's probably to make it easier to support backreferences (\0-\9) without having any special cases.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top