long otherValue = other.value; long result = value - otherValue; if (subtractionOverflowed(value, otherValue, result)) { return subtractAsBignum(context, other); } return newFixnum(context.getRuntime(), result);
long otherValue = other.value; long result = value + otherValue; if (additionOverflowed(value, otherValue, result)) { return addAsBignum(context, other); } return newFixnum(context.getRuntime(), result);
Clone fragments detected by clone detection tool
File path: /jruby-1.4.0/src/org/jruby/RubyFixnum.java File path: /jruby-1.4.0/src/org/jruby/RubyFixnum.java
Method name: IRubyObject subtractFixnum(ThreadContext, RubyFixnum) Method name: IRubyObject addFixnum(ThreadContext, RubyFixnum)
Number of AST nodes: 5 Number of AST nodes: 5
1
long otherValue = other.value;
1
long otherValue = other.value;
2
        long result = value - otherValue;
2
        long result = value + otherValue;
3
        if (subtractionOverflowed(value, otherValue, result)) {
3
        if (additionOverflowed(value, otherValue, result)) {
4
            return subtractAsBignum(context, other);
4
            return addAsBignum(context, other);
5
        }
5
        }
6
        return newFixnum(context.getRuntime(), result);
6
        return newFixnum(context.getRuntime(), result);
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.2
Clones locationClones are declared in the same class
Number of node comparisons13
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements4
    Number of unmapped statements in the first code fragment1
    Number of unmapped statements in the second code fragment1
    Time elapsed for statement mapping (ms)1.5
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
    1
    long otherValue = other.value;
    1
    long otherValue = other.value;
                                                                        
    2
    long result = value + otherValue;
    Preondition Violations
    Unmatched statement long result=value + otherValue; cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    2
    long result = value + otherValue;
    2
    long result = value - otherValue;
    2
    long result = value - otherValue;
    Preondition Violations
    Unmatched statement long result=value - otherValue; cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                                                        
    3
    if (subtractionOverflowed(value, otherValue, result))
    3
    if (subtractionOverflowed(value, otherValue, result))
    3
    if (additionOverflowed(value, otherValue, result))
    Differences
    Expression1Expression2Difference
    subtractionOverflowedadditionOverflowedMETHOD_INVOCATION_NAME_MISMATCH
    Preondition Violations
    Expression subtractionOverflowed(value,otherValue,result) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    • Inline private method subtractionOverflowed
    Expression additionOverflowed(value,otherValue,result) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    • Inline private method additionOverflowed
    3
    if (additionOverflowed(value, otherValue, result))
    4
    return subtractAsBignum(context, other);
    4
    return subtractAsBignum(context, other);
    4
    return addAsBignum(context, other);
    Differences
    Expression1Expression2Difference
    subtractAsBignumaddAsBignumMETHOD_INVOCATION_NAME_MISMATCH
    4
    return addAsBignum(context, other);
    5
    return newFixnum(context.getRuntime(), result);
    5
    return newFixnum(context.getRuntime(), result);
    Precondition Violations (4)
    Row Violation
    1Unmatched statement long result=value + otherValue; cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    2Unmatched statement long result=value - otherValue; cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    3Expression subtractionOverflowed(value,otherValue,result) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    4Expression additionOverflowed(value,otherValue,result) cannot be parameterized, because it has dependencies to/from statements that will be extracted