while (llen > 0) {
if (padLen <= 1) {
bytes[p++] = padBytes[padP];
llen--;
} else if (llen > padCharLen) {
System.arraycopy(padBytes, padP, bytes, p, padLen);
p += padLen;
llen -= padCharLen;
} else {
int padPP = padSinglebyte ? padP + llen : StringSupport.nth(enc, padBytes, padP, padP + padLen, llen);
n = padPP - padP;
System.arraycopy(padBytes, padP, bytes, p, n);
p += n;
break;
}
}
while (rlen > 0) {
if (padLen <= 1) {
bytes[p++] = padBytes[padP];
rlen--;
} else if (rlen > padCharLen) {
System.arraycopy(padBytes, padP, bytes, p, padLen);
p += padLen;
rlen -= padCharLen;
} else {
int padPP = padSinglebyte ? padP + rlen : StringSupport.nth(enc, padBytes, padP, padP + padLen, rlen);
n = padPP - padP;
System.arraycopy(padBytes, padP, bytes, p, n);
p += n;
break;
}
}
Clone fragments detected by clone detection tool
File path: /jruby-1.4.0/src/org/jruby/RubyString.java
|
|
File path: /jruby-1.4.0/src/org/jruby/RubyString.java
|
Method name: RubyString justifyCommon(Ruby, ByteList, int, boolean, Encoding, int, int)
|
|
Method name: RubyString justifyCommon(Ruby, ByteList, int, boolean, Encoding, int, int)
|
Number of AST nodes: 13
|
|
Number of AST nodes: 13
|
|
1 | while (llen > 0) {↵ | | 1 | while (rlen > 0) {↵
|
2 | if (padLen <= 1) { ↵ | | 2 | if (padLen <= 1) { ↵
|
3 | bytes[p++] = padBytes[padP];↵ | | 3 | bytes[p++] = padBytes[padP];↵
|
4 | llen--;↵ | | 4 | rlen--;↵
|
5 | } else if (llen > padCharLen) {↵ | | 5 | } else if (rlen > padCharLen) {↵
|
6 | System.arraycopy(padBytes, padP, bytes, p, padLen);↵ | | 6 | System.arraycopy(padBytes, padP, bytes, p, padLen);↵
|
7 | p += padLen;↵ | | 7 | p += padLen;↵
|
8 | llen -= padCharLen;↵ | | 8 | rlen -= padCharLen;↵
|
9 | } else {↵ | | 9 | } else {↵
|
10 | int padPP = padSinglebyte ? padP + llen : StringSupport.nth(enc, padBytes, padP, padP + padLen, llen);↵ | | 10 | int padPP = padSinglebyte ? padP + rlen : StringSupport.nth(enc, padBytes, padP, padP + padLen, rlen);↵
|
11 | n = padPP - padP;↵ | | 11 | n = padPP - padP;↵
|
12 | System.arraycopy(padBytes, padP, bytes, p, n);↵ | | 12 | System.arraycopy(padBytes, padP, bytes, p, n);↵
|
13 | p += n;↵ | | 13 | p += n;↵
|
14 | break;↵ | | 14 | break;↵
|
15 | }↵ | | 15 | }↵
|
16 | } | | 16 | }
|
See real code fragment |
|
See real code fragment |
Summary
Number of common nesting structure subtrees | 1 |
Number of refactorable cases | 0 |
Number of non-refactorable cases | 1 |
Time elapsed for finding largest common nesting structure subtrees (ms) | 0.6 |
Clones location | Clones are in the same method |
Number of node comparisons | 120 |
-
{Non-refactorable}
Mapping Summary
Number of mapped statements | 13 |
Number of unmapped statements in the first code fragment | 0 |
Number of unmapped statements in the second code fragment | 0 |
Time elapsed for statement mapping (ms) | 8.9 |
Clone type | Type 2 |
Mapped Statements
ID |
Statement |
|
ID |
Statement |
13 | while (llen > 0) | | 28 | while (rlen > 0) |
14 | | | 29 | |
15 | bytes[p++] = padBytes[padP]; | | 30 | bytes[p++] = padBytes[padP]; |
16 | | | 31 | |
17 | else if (llen > padCharLen) | | 32 | else if (rlen > padCharLen) |
18 | System.arraycopy(padBytes, padP, bytes, p, padLen); | | 33 | System.arraycopy(padBytes, padP, bytes, p, padLen); |
19 | | | 34 | |
20 | | | 35 | |
| | | | |
21 | int padPP = padSinglebyte ? padP + llen : StringSupport.nth(enc, padBytes, padP, padP + padLen, llen); | | 36 | int padPP = padSinglebyte ? padP + rlen : StringSupport.nth(enc, padBytes, padP, padP + padLen, rlen); |
22 | | | 37 | |
23 | System.arraycopy(padBytes, padP, bytes, p, n); | | 38 | System.arraycopy(padBytes, padP, bytes, p, n); |
24 | | | 39 | |
25 | | | 40 | |
Precondition Violations (1)
Row |
Violation |
1 | Clone fragment #1 returns variables bytes, p , while Clone fragment #2 returns variables p |