MCPcopy Index your code
hub / github.com/davidgiven/luje / replace0

Method replace0

lib/java/lang/AbstractStringBuilder.java:386–428  ·  view source on GitHub ↗
(int start, int end, String string)

Source from the content-addressed store, hash-verified

384 }
385
386 final void replace0(int start, int end, String string) {
387 if (start >= 0) {
388 if (end > count) {
389 end = count;
390 }
391 if (end > start) {
392 int stringLength = string.length();
393 int diff = end - start - stringLength;
394 if (diff > 0) { // replacing with fewer characters
395 if (!shared) {
396 // index == count case is no-op
397 System.arraycopy(value, end, value, start
398 + stringLength, count - end);
399 } else {
400 char[] newData = new char[value.length];
401 System.arraycopy(value, 0, newData, 0, start);
402 // index == count case is no-op
403 System.arraycopy(value, end, newData, start
404 + stringLength, count - end);
405 value = newData;
406 shared = false;
407 }
408 } else if (diff < 0) {
409 // replacing with more characters...need some room
410 move(-diff, end);
411 } else if (shared) {
412 value = value.clone();
413 shared = false;
414 }
415 string.getChars(0, stringLength, value, start);
416 count -= diff;
417 return;
418 }
419 if (start == end) {
420 if (string == null) {
421 throw new NullPointerException();
422 }
423 insert0(start, string);
424 return;
425 }
426 }
427 throw new StringIndexOutOfBoundsException();
428 }
429
430 final void reverse0() {
431 if (count < 2) {

Callers 2

replaceMethod · 0.80
replaceMethod · 0.80

Calls 6

arraycopyMethod · 0.95
moveMethod · 0.95
insert0Method · 0.95
lengthMethod · 0.65
cloneMethod · 0.45
getCharsMethod · 0.45

Tested by

no test coverage detected