mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-28 15:24:43 +02:00
8223593: Refactor code for reallocating storage
Reviewed-by: prappo, plevart, rriggs, smarks
This commit is contained in:
parent
54d0b2a8d6
commit
218204b1a3
11 changed files with 129 additions and 247 deletions
|
@ -43,6 +43,7 @@ import java.util.function.Predicate;
|
|||
import java.util.stream.Stream;
|
||||
import java.util.stream.StreamSupport;
|
||||
|
||||
import jdk.internal.util.ArraysSupport;
|
||||
|
||||
/**
|
||||
* A compiled representation of a regular expression.
|
||||
|
@ -2315,13 +2316,15 @@ loop: for(int x=0, offset=0; x<nCodePoints; x++, offset+=len) {
|
|||
}
|
||||
}
|
||||
|
||||
private void append(int ch, int len) {
|
||||
if (len >= buffer.length) {
|
||||
int[] tmp = new int[len+len];
|
||||
System.arraycopy(buffer, 0, tmp, 0, len);
|
||||
buffer = tmp;
|
||||
private void append(int ch, int index) {
|
||||
int len = buffer.length;
|
||||
if (index - len >= 0) {
|
||||
len = ArraysSupport.newLength(len,
|
||||
1 + index - len, /* minimum growth */
|
||||
len /* preferred growth */);
|
||||
buffer = Arrays.copyOf(buffer, len);
|
||||
}
|
||||
buffer[len] = ch;
|
||||
buffer[index] = ch;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue