It's probably to make it easier to support backreferences (\0
-\9
) without having any special cases.
Why use magic number in the implementation of regex in java?
-
22-09-2022 - |
سؤال
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?
المحلول
لا تنتمي إلى StackOverflow