long n = RubyNumeric.num2long(arg0); if (n > realLength) { n = realLength; } else if (n < 0) { throw getRuntime().newArgumentError("negative array size (or size too big)"); } return makeShared(begin + realLength - (int) n, (int) n, getRuntime().getArray());
long n = RubyNumeric.num2long(arg0); if (n > realLength) { n = realLength; } else if (n < 0) { throw getRuntime().newArgumentError("negative array size (or size too big)"); } return makeShared(begin, (int) n, getRuntime().getArray());
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 last(IRubyObject) Method name: IRubyObject first(IRubyObject)
Number of AST nodes: 6 Number of AST nodes: 6
1
long n = RubyNumeric.num2long(arg0);
1
long n = RubyNumeric.num2long(arg0);
2
        if (n > realLength) {
2
        if (n > realLength) {
3
            n = realLength;
3
            n = realLength;
4
        } else if (n < 0) {
4
        } else if (n < 0) {
5
            throw getRuntime().newArgumentError("negative array size (or size too big)");
5
            throw getRuntime().newArgumentError("negative array size (or size too big)");
6
        }
6
        }
7
        return makeShared(begin + realLength - (int) n, (int) n, getRuntime().getArray());
7
        return makeShared(begin, (int) n, getRuntime().getArray());
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 comparisons17
  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)1.5
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
    1
    long n = RubyNumeric.num2long(arg0);
    1
    long n = RubyNumeric.num2long(arg0);
    2
    if (n > realLength)
    2
    if (n > realLength)
    3
    n = realLength;
    3
    n = realLength;
    4
    else if (n < 0)
    4
    else if (n < 0)
    5
    throw getRuntime().newArgumentError("negative array size (or size too big)");
    5
    throw getRuntime().newArgumentError("negative array size (or size too big)");
    6
    return makeShared(begin + realLength - (int)n, (int)n, getRuntime().getArray());
    6
    return makeShared(begin + realLength - (int)n, (int)n, getRuntime().getArray());
    6
    return makeShared(begin, (int)n, getRuntime().getArray());
    Differences
    Expression1Expression2Difference
    begin + realLength - (int)nbeginTYPE_COMPATIBLE_REPLACEMENT
    Preondition Violations
    Expression begin + realLength - (int)n cannot be parameterized, because it has dependencies to/from statements that will be extracted
    6
    return makeShared(begin, (int)n, getRuntime().getArray());
    Precondition Violations (1)
    Row Violation
    1Expression begin + realLength - (int)n cannot be parameterized, because it has dependencies to/from statements that will be extracted