boolean modify = false; while (s < end) { int c = bytes[s] & 0xff; if (ASCII.isUpper(c)) { bytes[s] = AsciiTables.ToLowerCaseTable[c]; modify = true; } s++; } return modify ? this : runtime.getNil();
boolean modify = false; while (s < end) { int c = bytes[s] & 0xff; if (ASCII.isLower(c)) { bytes[s] = AsciiTables.ToUpperCaseTable[c]; modify = true; } s++; } 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 singleByteDowncase(Ruby, byte[], int, int) Method name: IRubyObject singleByteUpcase(Ruby, byte[], int, int)
Number of AST nodes: 8 Number of AST nodes: 8
1
boolean modify = false;
1
boolean modify = false;
2
        while (s < end) {
2
        while (s < end) {
3
            int c = bytes[s] & 0xff;
3
            int c = bytes[s] & 0xff;
4
            if (ASCII.isUpper(c)) {
4
            if (ASCII.isLower(c)) {
5
                bytes[s] = AsciiTables.ToLowerCaseTable[c];
5
                bytes[s] = AsciiTables.ToUpperCaseTable[c];
6
                modify = true;
6
                modify = true;
7
            }
7
            }
8
            s++;
8
            s++;
9
        }
9
        }
10
        return modify ? this : runtime.getNil();
10
        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)0.3
Clones locationClones are declared in the same class
Number of node comparisons22
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements8
    Number of unmapped statements in the first code fragment0
    Number of unmapped statements in the second code fragment0
    Time elapsed for statement mapping (ms)3.0
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
    1
    boolean modify = false;
    1
    boolean modify = false;
    2
    while (s < end)
    2
    while (s < end)
    3
    int c = bytes[s] & 0xff;
    3
    int c = bytes[s] & 0xff;
    4
    if (ASCII.isUpper(c))
    4
    if (ASCII.isUpper(c))
    4
    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
    4
    if (ASCII.isLower(c))
    5
    bytes[s] = AsciiTables.ToLowerCaseTable[c];
    5
    bytes[s] = AsciiTables.ToLowerCaseTable[c];
    5
    bytes[s] = AsciiTables.ToUpperCaseTable[c];
    Differences
    Expression1Expression2Difference
    ToLowerCaseTableToUpperCaseTableVARIABLE_NAME_MISMATCH
    5
    bytes[s] = AsciiTables.ToUpperCaseTable[c];
    6
    modify = true;
    6
    modify = true;
    7
    s++;
    7
    s++;
    8
    return modify ? this : runtime.getNil();
    8
    return modify ? this : runtime.getNil();
    Precondition Violations (2)
    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