Ruby runtime = context.getRuntime(); for (int i = begin; i < begin + realLength; i++) { IRubyObject v = values[i]; if (v instanceof RubyArray) { RubyArray arr = (RubyArray)v; if (arr.realLength > 0 && equalInternal(context, arr.values[arr.begin], key)) return arr; } } return runtime.getNil();
Ruby runtime = context.getRuntime(); for (int i = begin; i < begin + realLength; i++) { IRubyObject v = values[i]; if (v instanceof RubyArray) { RubyArray arr = (RubyArray)v; if (arr.realLength > 1 && equalInternal(context, arr.values[arr.begin + 1], value)) return arr; } } return runtime.getNil();
Clone fragments detected by clone detection tool
File path: /jruby-1.4.0/src/org/jruby/RubyArray.java File path: /jruby-1.4.0/src/org/jruby/RubyArray.java
Method name: IRubyObject assoc(ThreadContext, IRubyObject) Method name: IRubyObject rassoc(ThreadContext, IRubyObject)
Number of AST nodes: 8 Number of AST nodes: 8
1
Ruby runtime = context.getRuntime();
1
Ruby runtime = context.getRuntime();
2
        for (int i = begin; i < begin + realLength; i++) {
2
        for (int i = begin; i < begin + realLength; i++) {
3
            IRubyObject v = values[i];
3
            IRubyObject v = values[i];
4
            if (v instanceof RubyArray) {
4
            if (v instanceof RubyArray) {
5
                RubyArray arr = (RubyArray)v;
5
                RubyArray arr = (RubyArray)v;
6
                if (arr.realLength > 0 && equalInternal(context, arr.values[arr.begin], key)) return arr;
6
                if (arr.realLength > 1 && equalInternal(context, arr.values[arr.begin + 1], value)) return arr;
7
            }
7
            }
8
        }
8
        }
9
        return runtime.getNil();
9
        return 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.8
Clones locationClones are declared in the same class
Number of node comparisons16
  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)1.8
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
    1
    Ruby runtime = context.getRuntime();
    1
    Ruby runtime = context.getRuntime();
    2
    for (int i = begin; i < begin + realLength; i++)
    2
    for (int i = begin; i < begin + realLength; i++)
    3
    IRubyObject v = values[i];
    3
    IRubyObject v = values[i];
    4
    if (v instanceof RubyArray)
    4
    if (v instanceof RubyArray)
    5
    RubyArray arr = (RubyArray)v;
    5
    RubyArray arr = (RubyArray)v;
    6
    if (arr.realLength > 0 && equalInternal(context, arr.values[arr.begin], key))
    6
    if (arr.realLength > 0 && equalInternal(context, arr.values[arr.begin], key))
    6
    if (arr.realLength > 1 && equalInternal(context, arr.values[arr.begin + 1], value))
    Differences
    Expression1Expression2Difference
    01LITERAL_VALUE_MISMATCH
    arr.beginarr.begin + 1TYPE_COMPATIBLE_REPLACEMENT
    keyvalueVARIABLE_NAME_MISMATCH
    Preondition Violations
    Expression arr.begin cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression arr.begin + 1 cannot be parameterized, because it has dependencies to/from statements that will be extracted
    6
    if (arr.realLength > 1 && equalInternal(context, arr.values[arr.begin + 1], value))
    7
    return arr;
    7
    return arr;
    8
    return runtime.getNil();
    8
    return runtime.getNil();
    Precondition Violations (2)
    Row Violation
    1Expression arr.begin cannot be parameterized, because it has dependencies to/from statements that will be extracted
    2Expression arr.begin + 1 cannot be parameterized, because it has dependencies to/from statements that will be extracted