if (methodName.equals("+")) return new Fixnum(_value + ((Fixnum)arg)._value); else if (methodName.equals("-")) return new Fixnum(_value - ((Fixnum)arg)._value); else if (methodName.equals("*")) return new Fixnum(_value * ((Fixnum)arg)._value); else if (methodName.equals("/")) { Long divisor = ((Fixnum)arg)._value; return divisor == 0L ? null : new Fixnum(_value / divisor); // If divisor is zero, don't simplify! }
if (arg instanceof Float) { if (methodName.equals("+")) return new Float(_value + ((Float)arg)._value); else if (methodName.equals("-")) return new Float(_value - ((Float)arg)._value); else if (methodName.equals("*")) return new Float(_value * ((Float)arg)._value); else if (methodName.equals("/")) { Double divisor = ((Float)arg)._value; return divisor == 0.0 ? null : new Float(_value / divisor); // If divisor is zero, don't simplify! } }
Clone fragments detected by clone detection tool
File path: /jruby-1.4.0/src/org/jruby/compiler/ir/operands/Fixnum.java File path: /jruby-1.4.0/src/org/jruby/compiler/ir/operands/Fixnum.java
Method name: Constant computeValue(String, Constant) Method name: Constant computeValue(String, Constant)
Number of AST nodes: 9 Number of AST nodes: 10
1
if (arg instanceof Float) {
1
if (methodName.equals("+"))
2
            if (methodName.equals("+"))
2
                return new Fixnum(_value + ((Fixnum)arg)._value);
3
                return new Float(_value + ((Float)arg)._value);
3
            else if (methodName.equals("-"))
4
            else if (methodName.equals("-"))
4
                return new Fixnum(_value - ((Fixnum)arg)._value);
5
                return new Float(_value - ((Float)arg)._value);
5
            else if (methodName.equals("*"))
6
            else if (methodName.equals("*"))
6
                return new Fixnum(_value * ((Fixnum)arg)._value);
7
                return new Float(_value * ((Float)arg)._value);
7
            else if (methodName.equals("/")) {
8
            else if (methodName.equals("/")) {
8
                Long divisor = ((Fixnum)arg)._value;
9
                Double divisor = ((Float)arg)._value;
9
                return divisor == 0L ? null : new Fixnum(_value / divisor); // If divisor is zero, don't simplify!
10
                return divisor == 0.0 ? null : new Float(_value / divisor); // If divisor is zero, don't simplify!
10
            }
11
            }
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)1.4
Clones locationClones are in the same method
Number of node comparisons58
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements9
    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.0
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
    2
    if (methodName.equals("+"))
    12
    if (methodName.equals("+"))
    3
    return new Fixnum(_value + ((Fixnum)arg)._value);
    3
    return new Fixnum(_value + ((Fixnum)arg)._value);
    13
    return new Float(_value + ((Float)arg)._value);
    Differences
    Expression1Expression2Difference
    org.jruby.compiler.ir.operands.Fixnumorg.jruby.compiler.ir.operands.FloatSUBCLASS_TYPE_MISMATCH
    org.jruby.compiler.ir.operands.Fixnumorg.jruby.compiler.ir.operands.FloatSUBCLASS_TYPE_MISMATCH
    13
    return new Float(_value + ((Float)arg)._value);
    4
    else if (methodName.equals("-"))
    14
    else if (methodName.equals("-"))
    5
    return new Fixnum(_value - ((Fixnum)arg)._value);
    5
    return new Fixnum(_value - ((Fixnum)arg)._value);
    15
    return new Float(_value - ((Float)arg)._value);
    Differences
    Expression1Expression2Difference
    org.jruby.compiler.ir.operands.Fixnumorg.jruby.compiler.ir.operands.FloatSUBCLASS_TYPE_MISMATCH
    org.jruby.compiler.ir.operands.Fixnumorg.jruby.compiler.ir.operands.FloatSUBCLASS_TYPE_MISMATCH
    15
    return new Float(_value - ((Float)arg)._value);
    6
    else if (methodName.equals("*"))
    16
    else if (methodName.equals("*"))
    7
    return new Fixnum(_value * ((Fixnum)arg)._value);
    7
    return new Fixnum(_value * ((Fixnum)arg)._value);
    17
    return new Float(_value * ((Float)arg)._value);
    Differences
    Expression1Expression2Difference
    org.jruby.compiler.ir.operands.Fixnumorg.jruby.compiler.ir.operands.FloatSUBCLASS_TYPE_MISMATCH
    org.jruby.compiler.ir.operands.Fixnumorg.jruby.compiler.ir.operands.FloatSUBCLASS_TYPE_MISMATCH
    17
    return new Float(_value * ((Float)arg)._value);
    8
    else if (methodName.equals("/"))
    18
    else if (methodName.equals("/"))
    9
    Long divisor = ((Fixnum)arg)._value;
    9
    Long divisor = ((Fixnum)arg)._value;
    19
    Double divisor = ((Float)arg)._value;
    Differences
    Expression1Expression2Difference
    java.lang.Longjava.lang.DoubleSUBCLASS_TYPE_MISMATCH
    java.lang.Longjava.lang.DoubleSUBCLASS_TYPE_MISMATCH
    org.jruby.compiler.ir.operands.Fixnumorg.jruby.compiler.ir.operands.FloatSUBCLASS_TYPE_MISMATCH
    19
    Double divisor = ((Float)arg)._value;
    10
    return divisor == 0L ? null : new Fixnum(_value / divisor);
    10
    return divisor == 0L ? null : new Fixnum(_value / divisor);
    20
    return divisor == 0.0 ? null : new Float(_value / divisor);
    Differences
    Expression1Expression2Difference
    java.lang.Longjava.lang.DoubleSUBCLASS_TYPE_MISMATCH
    0L0.0LITERAL_VALUE_MISMATCH
    org.jruby.compiler.ir.operands.Fixnumorg.jruby.compiler.ir.operands.FloatSUBCLASS_TYPE_MISMATCH
    java.lang.Longjava.lang.DoubleSUBCLASS_TYPE_MISMATCH
    Preondition Violations
    Expression new Fixnum(_value / divisor) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression new Float(_value / divisor) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    20
    return divisor == 0.0 ? null : new Float(_value / divisor);
    Precondition Violations (2)
    Row Violation
    1Expression new Fixnum(_value / divisor) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    2Expression new Float(_value / divisor) cannot be parameterized, because it has dependencies to/from statements that will be extracted