Ruby runtime = context.getRuntime(); DynamicScope scope = context.getCurrentScope(); IRubyObject backref = scope.getBackRef(runtime); if (backref instanceof RubyMatchData) ((RubyMatchData)backref).use(); IRubyObject s = RuntimeHelpers.invoke( context, this, "gsub", RubyRegexp.newDummyRegexp(runtime, Numeric.ComplexPatterns.underscores_pat), runtime.newString(new ByteList(new byte[]{'_'}))); RubyArray a = RubyRational.str_to_r_internal(context, s); scope.setBackRef(backref); if (!a.eltInternal(0).isNil()) { return a.eltInternal(0); } else { return RubyRational.newRationalCanonicalize(context, RubyFixnum.zero(runtime)); }
Ruby runtime = context.getRuntime(); DynamicScope scope = context.getCurrentScope(); IRubyObject backref = scope.getBackRef(runtime); if (backref instanceof RubyMatchData) ((RubyMatchData)backref).use(); IRubyObject s = RuntimeHelpers.invoke( context, this, "gsub", RubyRegexp.newDummyRegexp(runtime, Numeric.ComplexPatterns.underscores_pat), runtime.newString(new ByteList(new byte[]{'_'}))); RubyArray a = RubyComplex.str_to_c_internal(context, s); scope.setBackRef(backref); if (!a.eltInternal(0).isNil()) { return a.eltInternal(0); } else { return RubyComplex.newComplexCanonicalize(context, RubyFixnum.zero(runtime)); }
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 to_r(ThreadContext) Method name: IRubyObject to_c(ThreadContext)
Number of AST nodes: 11 Number of AST nodes: 11
1
Ruby runtime = context.getRuntime();
1
Ruby runtime = context.getRuntime();
2
        DynamicScope scope = context.getCurrentScope();
2
        DynamicScope scope = context.getCurrentScope();
3
        IRubyObject backref = scope.getBackRef(runtime);
3
        IRubyObject backref = scope.getBackRef(runtime);
4
        if (backref instanceof RubyMatchData) ((RubyMatchData)backref).use();
4
        if (backref instanceof RubyMatchData) ((RubyMatchData)backref).use();
5
        IRubyObject s = RuntimeHelpers.invoke(
5
        IRubyObject s = RuntimeHelpers.invoke(
6
                context, this, "gsub",
6
                context, this, "gsub",
7
                RubyRegexp.newDummyRegexp(runtime, Numeric.ComplexPatterns.underscores_pat),
7
                RubyRegexp.newDummyRegexp(runtime, Numeric.ComplexPatterns.underscores_pat),
8
                runtime.newString(new ByteList(new byte[]{'_'})));
8
                runtime.newString(new ByteList(new byte[]{'_'})));
9
        RubyArray a = RubyRational.str_to_r_internal(context, s);
9
        RubyArray a = RubyComplex.str_to_c_internal(context, s);
10
        scope.setBackRef(backref);
10
        scope.setBackRef(backref);
11
        if (!a.eltInternal(0).isNil()) {
11
        if (!a.eltInternal(0).isNil()) {
12
            return a.eltInternal(0);
12
            return a.eltInternal(0);
13
        } else {
13
        } else {
14
            return RubyRational.newRationalCanonicalize(context, RubyFixnum.zero(runtime));
14
            return RubyComplex.newComplexCanonicalize(context, RubyFixnum.zero(runtime));
15
        }
15
        }
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.5
Clones locationClones are declared in the same class
Number of node comparisons40
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements11
    Number of unmapped statements in the first code fragment0
    Number of unmapped statements in the second code fragment0
    Time elapsed for statement mapping (ms)106.3
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
    1
    Ruby runtime = context.getRuntime();
    1
    Ruby runtime = context.getRuntime();
    2
    DynamicScope scope = context.getCurrentScope();
    2
    DynamicScope scope = context.getCurrentScope();
    3
    IRubyObject backref = scope.getBackRef(runtime);
    3
    IRubyObject backref = scope.getBackRef(runtime);
    4
    if (backref instanceof RubyMatchData)
    4
    if (backref instanceof RubyMatchData)
    5
    ((RubyMatchData)backref).use();
    5
    ((RubyMatchData)backref).use();
    6
    IRubyObject s = RuntimeHelpers.invoke(context, this, "gsub", RubyRegexp.newDummyRegexp(runtime, Numeric.ComplexPatterns.underscores_pat), runtime.newString(new ByteList(new byte[] {'_'})));
    6
    IRubyObject s = RuntimeHelpers.invoke(context, this, "gsub", RubyRegexp.newDummyRegexp(runtime, Numeric.ComplexPatterns.underscores_pat), runtime.newString(new ByteList(new byte[] {'_'})));
    7
    RubyArray a = RubyRational.str_to_r_internal(context, s);
    7
    RubyArray a = RubyRational.str_to_r_internal(context, s);
    7
    RubyArray a = RubyComplex.str_to_c_internal(context, s);
    Differences
    Expression1Expression2Difference
    str_to_r_internalstr_to_c_internalMETHOD_INVOCATION_NAME_MISMATCH
    org.jruby.RubyRationalorg.jruby.RubyComplexSUBCLASS_TYPE_MISMATCH
    Preondition Violations
    Expression RubyRational.str_to_r_internal(context,s) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression RubyComplex.str_to_c_internal(context,s) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    7
    RubyArray a = RubyComplex.str_to_c_internal(context, s);
    8
    scope.setBackRef(backref);
    8
    scope.setBackRef(backref);
    9
    if (!a.eltInternal(0).isNil())
    9
    if (!a.eltInternal(0).isNil())
    10
    return a.eltInternal(0);
    10
    return a.eltInternal(0);
    else
    else
    11
    return RubyRational.newRationalCanonicalize(context, RubyFixnum.zero(runtime));
    11
    return RubyRational.newRationalCanonicalize(context, RubyFixnum.zero(runtime));
    11
    return RubyComplex.newComplexCanonicalize(context, RubyFixnum.zero(runtime));
    Differences
    Expression1Expression2Difference
    newRationalCanonicalizenewComplexCanonicalizeMETHOD_INVOCATION_NAME_MISMATCH
    org.jruby.RubyRationalorg.jruby.RubyComplexSUBCLASS_TYPE_MISMATCH
    Preondition Violations
    Expression RubyRational.newRationalCanonicalize(context,RubyFixnum.zero(runtime)) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression RubyComplex.newComplexCanonicalize(context,RubyFixnum.zero(runtime)) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    11
    return RubyComplex.newComplexCanonicalize(context, RubyFixnum.zero(runtime));
    Precondition Violations (4)
    Row Violation
    1Expression RubyRational.str_to_r_internal(context,s) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    2Expression RubyComplex.str_to_c_internal(context,s) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    3Expression RubyRational.newRationalCanonicalize(context,RubyFixnum.zero(runtime)) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    4Expression RubyComplex.newComplexCanonicalize(context,RubyFixnum.zero(runtime)) cannot be parameterized, because it has dependencies to/from statements that will be extracted