| 362 | } |
| 363 | |
| 364 | private void move(int size, int index) { |
| 365 | int newSize; |
| 366 | if (value.length - count >= size) { |
| 367 | if (!shared) { |
| 368 | System.arraycopy(value, index, value, index + size, count |
| 369 | - index); // index == count case is no-op |
| 370 | return; |
| 371 | } |
| 372 | newSize = value.length; |
| 373 | } else { |
| 374 | int a = count + size, b = (value.length << 1) + 2; |
| 375 | newSize = a > b ? a : b; |
| 376 | } |
| 377 | |
| 378 | char[] newData = new char[newSize]; |
| 379 | System.arraycopy(value, 0, newData, 0, index); |
| 380 | // index == count case is no-op |
| 381 | System.arraycopy(value, index, newData, index + size, count - index); |
| 382 | value = newData; |
| 383 | shared = false; |
| 384 | } |
| 385 | |
| 386 | final void replace0(int start, int end, String string) { |
| 387 | if (start >= 0) { |