if (other instanceof RubyComplex) { RubyComplex otherComplex = (RubyComplex)other; return newComplex(context, getMetaClass(), f_add(context, real, otherComplex.real), f_add(context, image, otherComplex.image)); } else if (other instanceof RubyNumeric && f_real_p(context, other).isTrue()) { return newComplex(context, getMetaClass(), f_add(context, real, other), image); } return coerceBin(context, "+", other);
if (other instanceof RubyComplex) { RubyComplex otherComplex = (RubyComplex)other; return newComplex(context, getMetaClass(), f_sub(context, real, otherComplex.real), f_sub(context, image, otherComplex.image)); } else if (other instanceof RubyNumeric && f_real_p(context, other).isTrue()) { return newComplex(context, getMetaClass(), f_sub(context, real, other), image); } return coerceBin(context, "-", other);
Clone fragments detected by clone detection tool
File path: /jruby-1.4.0/src/org/jruby/RubyComplex.java File path: /jruby-1.4.0/src/org/jruby/RubyComplex.java
Method name: IRubyObject op_add(ThreadContext, IRubyObject) Method name: IRubyObject op_sub(ThreadContext, IRubyObject)
Number of AST nodes: 6 Number of AST nodes: 6
1
if (other instanceof RubyComplex) {
1
if (other instanceof RubyComplex) {
2
            RubyComplex otherComplex = (RubyComplex)other;
2
            RubyComplex otherComplex = (RubyComplex)other;
3
            return newComplex(context, getMetaClass(), 
3
            return newComplex(context, getMetaClass(), 
4
                              f_add(context, real, otherComplex.real),
4
                              f_sub(context, real, otherComplex.real),
5
                              f_add(context, image, otherComplex.image));
5
                              f_sub(context, image, otherComplex.image));
6
        } else if (other instanceof RubyNumeric && f_real_p(context, other).isTrue()) {
6
        } else if (other instanceof RubyNumeric && f_real_p(context, other).isTrue()) {
7
            return newComplex(context, getMetaClass(), f_add(context, real, other), image);
7
            return newComplex(context, getMetaClass(), f_sub(context, real, other), image);
8
        }
8
        }
9
        return coerceBin(context, "+", other);
9
        return coerceBin(context, "-", other);
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 comparisons21
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements6
    Number of unmapped statements in the first code fragment0
    Number of unmapped statements in the second code fragment0
    Time elapsed for statement mapping (ms)4.3
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
    1
    if (other instanceof RubyComplex)
    1
    if (other instanceof RubyComplex)
    2
    RubyComplex otherComplex = (RubyComplex)other;
    2
    RubyComplex otherComplex = (RubyComplex)other;
    3
    return newComplex(context, getMetaClass(), f_add(context, real, otherComplex.real), f_add(context, image, otherComplex.image));
    3
    return newComplex(context, getMetaClass(), f_add(context, real, otherComplex.real), f_add(context, image, otherComplex.image));
    3
    return newComplex(context, getMetaClass(), f_sub(context, real, otherComplex.real), f_sub(context, image, otherComplex.image));
    Differences
    Expression1Expression2Difference
    f_addf_subMETHOD_INVOCATION_NAME_MISMATCH
    f_addf_subMETHOD_INVOCATION_NAME_MISMATCH
    Preondition Violations
    Expression f_add(context,real,otherComplex.real) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression f_sub(context,real,otherComplex.real) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression f_add(context,image,otherComplex.image) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression f_sub(context,image,otherComplex.image) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    3
    return newComplex(context, getMetaClass(), f_sub(context, real, otherComplex.real), f_sub(context, image, otherComplex.image));
    4
    else if (other instanceof RubyNumeric && f_real_p(context, other).isTrue())
    4
    else if (other instanceof RubyNumeric && f_real_p(context, other).isTrue())
    5
    return newComplex(context, getMetaClass(), f_add(context, real, other), image);
    5
    return newComplex(context, getMetaClass(), f_add(context, real, other), image);
    5
    return newComplex(context, getMetaClass(), f_sub(context, real, other), image);
    Differences
    Expression1Expression2Difference
    f_addf_subMETHOD_INVOCATION_NAME_MISMATCH
    Preondition Violations
    Expression f_add(context,real,other) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression f_sub(context,real,other) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    5
    return newComplex(context, getMetaClass(), f_sub(context, real, other), image);
    6
    return coerceBin(context, "+", other);
    6
    return coerceBin(context, "+", other);
    6
    return coerceBin(context, "-", other);
    Differences
    Expression1Expression2Difference
    "+""-"LITERAL_VALUE_MISMATCH
    6
    return coerceBin(context, "-", other);
    Precondition Violations (6)
    Row Violation
    1Expression f_add(context,real,otherComplex.real) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    2Expression f_sub(context,real,otherComplex.real) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    3Expression f_add(context,image,otherComplex.image) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    4Expression f_sub(context,image,otherComplex.image) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    5Expression f_add(context,real,other) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    6Expression f_sub(context,real,other) cannot be parameterized, because it has dependencies to/from statements that will be extracted