boolean modify = false; int c; while (s < end) { if (enc.isAsciiCompatible() && Encoding.isAscii(c = bytes[s] & 0xff)) { if (ASCII.isUpper(c)) { bytes[s] = AsciiTables.ToLowerCaseTable[c]; modify = true; } s++; } else { c = codePoint(runtime, enc, bytes, s, end); if (enc.isUpper(c)) { enc.codeToMbc(toLower(enc, c), bytes, s); modify = true; } s += codeLength(runtime, enc, c); } } return modify ? this : runtime.getNil();
boolean modify = false; int c; while (s < end) { if (enc.isAsciiCompatible() && Encoding.isAscii(c = bytes[s] & 0xff)) { if (ASCII.isLower(c)) { bytes[s] = AsciiTables.ToUpperCaseTable[c]; modify = true; } s++; } else { c = codePoint(runtime, enc, bytes, s, end); if (enc.isLower(c)) { enc.codeToMbc(toUpper(enc, c), bytes, s); modify = true; } s += codeLength(runtime, enc, c); } } return modify ? this : runtime.getNil();
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: IRubyObject multiByteDowncase(Ruby, Encoding, byte[], int, int) Method name: IRubyObject multiByteUpcase(Ruby, Encoding, byte[], int, int)
Number of AST nodes: 14 Number of AST nodes: 14
1
boolean modify = false;
1
boolean modify = false;
2
        int c;
2
        int c;
3
        while (s < end) {
3
        while (s < end) {
4
            if (enc.isAsciiCompatible() && Encoding.isAscii(c = bytes[s] & 0xff)) {
4
            if (enc.isAsciiCompatible() && Encoding.isAscii(c = bytes[s] & 0xff)) {
5
                if (ASCII.isUpper(c)) {
5
                if (ASCII.isLower(c)) {
6
                    bytes[s] = AsciiTables.ToLowerCaseTable[c];
6
                    bytes[s] = AsciiTables.ToUpperCaseTable[c];
7
                    modify = true;
7
                    modify = true;
8
                }
8
                }
9
                s++;
9
                s++;
10
            } else {
10
            } else {
11
                c = codePoint(runtime, enc, bytes, s, end);
11
                c = codePoint(runtime, enc, bytes, s, end);
12
                if (enc.isUpper(c)) {
12
                if (enc.isLower(c)) {
13
                    enc.codeToMbc(toLower(enc, c), bytes, s);
13
                    enc.codeToMbc(toUpper(enc, c), bytes, s);
14
                    modify = true;
14
                    modify = true;
15
                }
15
                }
16
                s += codeLength(runtime, enc, c);
16
                s += codeLength(runtime, enc, c);
17
            }
17
            }
18
        }
18
        }
19
        return modify ? this : runtime.getNil();
19
        return modify ? this : runtime.getNil();
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)1.2
Clones locationClones are declared in the same class
Number of node comparisons54
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements14
    Number of unmapped statements in the first code fragment0
    Number of unmapped statements in the second code fragment0
    Time elapsed for statement mapping (ms)6.9
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
    1
    boolean modify = false;
    1
    boolean modify = false;
    2
    int c;
    2
    int c;
    3
    while (s < end)
    3
    while (s < end)
    4
    if (enc.isAsciiCompatible() && Encoding.isAscii(c = bytes[s] & 0xff))
    4
    if (enc.isAsciiCompatible() && Encoding.isAscii(c = bytes[s] & 0xff))
    5
    if (ASCII.isUpper(c))
    5
    if (ASCII.isUpper(c))
    5
    if (ASCII.isLower(c))
    Differences
    Expression1Expression2Difference
    isUpperisLowerMETHOD_INVOCATION_NAME_MISMATCH
    Preondition Violations
    Expression ASCII.isUpper(c) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression ASCII.isLower(c) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    5
    if (ASCII.isLower(c))
    6
    bytes[s] = AsciiTables.ToLowerCaseTable[c];
    6
    bytes[s] = AsciiTables.ToLowerCaseTable[c];
    6
    bytes[s] = AsciiTables.ToUpperCaseTable[c];
    Differences
    Expression1Expression2Difference
    ToLowerCaseTableToUpperCaseTableVARIABLE_NAME_MISMATCH
    6
    bytes[s] = AsciiTables.ToUpperCaseTable[c];
    7
    modify = true;
    7
    modify = true;
    8
    s++;
    8
    s++;
    else
    else
    9
    c = codePoint(runtime, enc, bytes, s, end);
    9
    c = codePoint(runtime, enc, bytes, s, end);
    10
    if (enc.isUpper(c))
    10
    if (enc.isUpper(c))
    10
    if (enc.isLower(c))
    Differences
    Expression1Expression2Difference
    isUpperisLowerMETHOD_INVOCATION_NAME_MISMATCH
    Preondition Violations
    Expression enc.isUpper(c) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression enc.isLower(c) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    10
    if (enc.isLower(c))
    11
    enc.codeToMbc(toLower(enc, c), bytes, s);
    11
    enc.codeToMbc(toLower(enc, c), bytes, s);
    11
    enc.codeToMbc(toUpper(enc, c), bytes, s);
    Differences
    Expression1Expression2Difference
    toLowertoUpperMETHOD_INVOCATION_NAME_MISMATCH
    Preondition Violations
    Expression toLower(enc,c) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression toUpper(enc,c) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    11
    enc.codeToMbc(toUpper(enc, c), bytes, s);
    12
    modify = true;
    12
    modify = true;
    13
    s += codeLength(runtime, enc, c);
    13
    s += codeLength(runtime, enc, c);
    14
    return modify ? this : runtime.getNil();
    14
    return modify ? this : runtime.getNil();
    Precondition Violations (6)
    Row Violation
    1Expression ASCII.isUpper(c) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    2Expression ASCII.isLower(c) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    3Expression enc.isUpper(c) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    4Expression enc.isLower(c) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    5Expression toLower(enc,c) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    6Expression toUpper(enc,c) cannot be parameterized, because it has dependencies to/from statements that will be extracted