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
        }
Summary
Number of common nesting structure subtrees1
Number of refactorable cases0
Number of non-refactorable cases1
Time elapsed for finding largest common nesting structure subtrees (ms)0.6
Clones locationClones are in the same method
Number of node comparisons120
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements13
    Number of unmapped statements in the first code fragment0
    Number of unmapped statements in the second code fragment0
    Time elapsed for statement mapping (ms)8.9
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
    13
    while (llen > 0)
    13
    while (llen > 0)
    28
    while (rlen > 0)
    Differences
    Expression1Expression2Difference
    llenrlenVARIABLE_NAME_MISMATCH
    28
    while (rlen > 0)
    14
    if (padLen <= 1)
    29
    if (padLen <= 1)
    15
    bytes[p++] = padBytes[padP];
    30
    bytes[p++] = padBytes[padP];
    16
    llen--;
    16
    llen--;
    31
    rlen--;
    Differences
    Expression1Expression2Difference
    llenrlenVARIABLE_NAME_MISMATCH
    31
    rlen--;
    17
    else if (llen > padCharLen)
    17
    else if (llen > padCharLen)
    32
    else if (rlen > padCharLen)
    Differences
    Expression1Expression2Difference
    llenrlenVARIABLE_NAME_MISMATCH
    32
    else if (rlen > padCharLen)
    18
    System.arraycopy(padBytes, padP, bytes, p, padLen);
    33
    System.arraycopy(padBytes, padP, bytes, p, padLen);
    19
    p += padLen;
    34
    p += padLen;
    20
    llen -= padCharLen;
    20
    llen -= padCharLen;
    35
    rlen -= padCharLen;
    Differences
    Expression1Expression2Difference
    llenrlenVARIABLE_NAME_MISMATCH
    35
    rlen -= padCharLen;
    else
    else
    21
    int padPP = padSinglebyte ? padP + llen : StringSupport.nth(enc, padBytes, padP, padP + padLen, llen);
    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);
    Differences
    Expression1Expression2Difference
    llenrlenVARIABLE_NAME_MISMATCH
    llenrlenVARIABLE_NAME_MISMATCH
    36
    int padPP = padSinglebyte ? padP + rlen : StringSupport.nth(enc, padBytes, padP, padP + padLen, rlen);
    22
    n = padPP - padP;
    37
    n = padPP - padP;
    23
    System.arraycopy(padBytes, padP, bytes, p, n);
    38
    System.arraycopy(padBytes, padP, bytes, p, n);
    24
    p += n;
    39
    p += n;
    25
    break;
    40
    break;
    Precondition Violations (1)
    Row Violation
    1Clone fragment #1 returns variables bytes, p , while Clone fragment #2 returns variables p