if (depth > 0) { return parent.getValue(offset, depth - 1); } assert offset < SIZE : SIZE_ERROR; switch (offset) { case 0: return variableValueZero; case 1: return variableValueOne; case 2: return variableValueTwo; case 3: return variableValueThree; default: throw new RuntimeException(SIZE_ERROR); }
if (depth > 0) { return parent.getValue(offset, depth - 1); } assert offset < SIZE : SIZE_ERROR; switch (offset) { case 0: return variableValueZero; case 1: return variableValueOne; default: throw new RuntimeException(SIZE_ERROR); }
Clone fragments detected by clone detection tool
File path: /jruby-1.4.0/src/org/jruby/runtime/scope/FourVarDynamicScope.java File path: /jruby-1.4.0/src/org/jruby/runtime/scope/TwoVarDynamicScope.java
Method name: IRubyObject getValue(int, int) Method name: IRubyObject getValue(int, int)
Number of AST nodes: 14 Number of AST nodes: 10
1
if (depth > 0) {
1
if (depth > 0) {
2
            return parent.getValue(offset, depth - 1);
2
            return parent.getValue(offset, depth - 1);
3
        }
3
        }
4
        assert offset < SIZE : SIZE_ERROR;
4
        assert offset < SIZE : SIZE_ERROR;
5
        switch (offset) {
5
        switch (offset) {
6
        case 0:
6
        case 0:
7
            return variableValueZero;
7
            return variableValueZero;
8
        case 1:
8
        case 1:
9
            return variableValueOne;
9
            return variableValueOne;
10
        case 2:
11
            return variableValueTwo;
12
        case 3:
13
            return variableValueThree;
14
        default:
10
        default:
15
            throw new RuntimeException(SIZE_ERROR);
11
            throw new RuntimeException(SIZE_ERROR);
16
        }
12
        }
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.1
Clones locationClones are in different classes having the same super class
Number of node comparisons53
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements10
    Number of unmapped statements in the first code fragment4
    Number of unmapped statements in the second code fragment0
    Time elapsed for statement mapping (ms)1.5
    Clone typeType 3
    Mapped Statements
    ID Statement ID Statement
    1
    if (depth > 0)
    1
    if (depth > 0)
    2
    return parent.getValue(offset, depth - 1);
    2
    return parent.getValue(offset, depth - 1);
    3
    assert offset < SIZE : SIZE_ERROR;
    3
    assert offset < SIZE : SIZE_ERROR;
    4
    switch (offset)
    4
    switch (offset)
    5
    case 0:
    5
    case 0:
    6
    return variableValueZero;
    6
    return variableValueZero;
    7
    case 1:
    7
    case 1:
    8
    return variableValueOne;
    8
    return variableValueOne;
    9
    case 2:
                        
    10
    return variableValueTwo;
    10
    return variableValueTwo;
    Preondition Violations
    Unmatched return variableValueTwo;
                                                            
    11
    case 3:
                          
    12
    return variableValueThree;
    12
    return variableValueThree;
    Preondition Violations
    Unmatched return variableValueThree;
                                                                
    13
    default:
    9
    default:
    14
    throw new RuntimeException(SIZE_ERROR);
    10
    throw new RuntimeException(SIZE_ERROR);
    Precondition Violations (2)
    Row Violation
    1Unmatched return variableValueTwo;
    2Unmatched return variableValueThree;