Object[]table = packedVTable; int hash = name.hashCode(); for (int i = 0; i < vTableSize; i++) { String n = (String)table[i]; if (n.hashCode() == hash && name.equals(n)) return true; } return false;
Object[]table = packedVTable; int hash = name.hashCode(); for (int i = 0; i < vTableSize; i++) { String n = (String)table[i]; if (n.hashCode() == hash && name.equals(n)) return table[i + MAX_PACKED]; } return null;
Clone fragments detected by clone detection tool
File path: /jruby-1.4.0/src/org/jruby/runtime/builtin/InstanceVariableTable.java File path: /jruby-1.4.0/src/org/jruby/runtime/builtin/InstanceVariableTable.java
Method name: boolean packedContains(String) Method name: Object packedFetch(String)
Number of AST nodes: 7 Number of AST nodes: 7
1
Object[]table = packedVTable;
1
Object[]table = packedVTable;
2
        int hash = name.hashCode();
2
        int hash = name.hashCode();
3
        for (int i = 0; i < vTableSize; i++) {
3
        for (int i = 0; i < vTableSize; i++) {
4
            String n = (String)table[i];
4
            String n = (String)table[i];
5
            if (n.hashCode() == hash && name.equals(n)) return true;
5
            if (n.hashCode() == hash && name.equals(n)) return table[i + MAX_PACKED];
6
        }
6
        }
7
        return false;
7
        return null;
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.4
Clones locationClones are declared in the same class
Number of node comparisons17
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements5
    Number of unmapped statements in the first code fragment2
    Number of unmapped statements in the second code fragment2
    Time elapsed for statement mapping (ms)0.9
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
    1
    Object[] table = packedVTable;
    1
    Object[] table = packedVTable;
    2
    int hash = name.hashCode();
    2
    int hash = name.hashCode();
    3
    for (int i = 0; i < vTableSize; i++)
    3
    for (int i = 0; i < vTableSize; i++)
    4
    String n = (String)table[i];
    4
    String n = (String)table[i];
    5
    if (n.hashCode() == hash && name.equals(n))
    5
    if (n.hashCode() == hash && name.equals(n))
                                                                    
    6
    return table[i + MAX_PACKED];
    Preondition Violations
    Unmatched statement return table[i + MAX_PACKED]; cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    Unmatched return table[i + MAX_PACKED];
    6
    return table[i + MAX_PACKED];
    6
    return true;
    6
    return true;
    Preondition Violations
    Unmatched return true;
                                  
                                  
    7
    return null;
    Preondition Violations
    Unmatched return null;
    7
    return null;
    7
    return false;
    7
    return false;
    Preondition Violations
    Unmatched return false;
                                    
    Precondition Violations (6)
    Row Violation
    1Unmatched statement return table[i + MAX_PACKED]; cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    2Unmatched return table[i + MAX_PACKED];
    3Unmatched return true;
    4Unmatched return null;
    5Unmatched return false;
    6Clone fragment #1 returns variables , while Clone fragment #2 returns variables table, i