long shift; boolean neg = false; for (;;) { if (other instanceof RubyFixnum) { shift = ((RubyFixnum)other).getLongValue(); if (shift < 0) { neg = true; shift = -shift; } break; } else if (other instanceof RubyBignum) { RubyBignum otherBignum = (RubyBignum)other; if (otherBignum.value.signum() >= 0) { IRubyObject tmp = otherBignum.checkShiftDown(this); if (!tmp.isNil()) return tmp; } else { neg = true; } shift = big2long(otherBignum); break; } other = other.convertToInteger(); } return bignorm(getRuntime(), neg ? value.shiftLeft((int)shift) : value.shiftRight((int)shift));
long shift; boolean neg = false; for (;;) { if (other instanceof RubyFixnum) { shift = ((RubyFixnum)other).getLongValue(); if (shift < 0) { neg = true; shift = -shift; } break; } else if (other instanceof RubyBignum) { RubyBignum otherBignum = (RubyBignum)other; if (otherBignum.value.signum() < 0) { IRubyObject tmp = otherBignum.checkShiftDown(this); if (!tmp.isNil()) return tmp; neg = true; } shift = big2long(otherBignum); break; } other = other.convertToInteger(); } return bignorm(getRuntime(), neg ? value.shiftRight((int)shift) : value.shiftLeft((int)shift));
Clone fragments detected by clone detection tool
File path: /jruby-1.4.0/src/org/jruby/RubyBignum.java File path: /jruby-1.4.0/src/org/jruby/RubyBignum.java
Method name: IRubyObject op_rshift(IRubyObject) Method name: IRubyObject op_lshift(IRubyObject)
Number of AST nodes: 20 Number of AST nodes: 20
1
long shift;
1
long shift;
2
        boolean neg = false;
2
        boolean neg = false;
3
        for (;;) {
3
        for (;;) {
4
            if (other instanceof RubyFixnum) {
4
            if (other instanceof RubyFixnum) {
5
                shift = ((RubyFixnum)other).getLongValue();
5
                shift = ((RubyFixnum)other).getLongValue();
6
                if (shift < 0) {
6
                if (shift < 0) {
7
                    neg = true;
7
                    neg = true;
8
                    shift = -shift;
8
                    shift = -shift;
9
                }
9
                }
10
                break;
10
                break;
11
            } else if (other instanceof RubyBignum) {
11
            } else if (other instanceof RubyBignum) {
12
                RubyBignum otherBignum = (RubyBignum)other;
12
                RubyBignum otherBignum = (RubyBignum)other;
13
                if (otherBignum.value.signum() &gt;= 0) {
13
                if (otherBignum.value.signum() &lt; 0) {
14
                    IRubyObject tmp = otherBignum.checkShiftDown(this);
14
                    IRubyObject tmp = otherBignum.checkShiftDown(this);
15
                    if (!tmp.isNil()) return tmp;
15
                    if (!tmp.isNil()) return tmp;
16
                } else {
16
      
17
                    neg = true;
17
              neg = true;
18
                }
18
                }
19
                shift = big2long(otherBignum);
19
                shift = big2long(otherBignum);
20
                break;
20
                break;
21
            }
21
            }
22
            other = other.convertToInteger();
22
            other = other.convertToInteger();
23
        }
23
        }
24
        return bignorm(getRuntime(), neg ? value.shiftLeft((int)shift) : value.shiftRight((int)shift));
24
        return bignorm(getRuntime(), neg ? value.shiftRight((int)shift) : value.shiftLeft((int)shift));
Summary
Number of common nesting structure subtrees2
Number of refactorable cases1
Number of non-refactorable cases1
Time elapsed for finding largest common nesting structure subtrees (ms)4.8
Clones locationClones are declared in the same class
Number of node comparisons27
  1. {Refactorable}
    Mapping Summary
    Number of mapped statements3
    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 1
    Mapped Statements
    ID Statement ID Statement
    13
    IRubyObject tmp = otherBignum.checkShiftDown(this);
    13
    IRubyObject tmp = otherBignum.checkShiftDown(this);
    14
    if (!tmp.isNil())
    14
    if (!tmp.isNil())
    15
    return tmp;
    15
    return tmp;
    Precondition Violations (0)
    Row Violation
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements4
    Number of unmapped statements in the first code fragment0
    Number of unmapped statements in the second code fragment0
    Time elapsed for statement mapping (ms)2.9
    Clone typeType 1
    Mapped Statements
    ID Statement ID Statement
    5
    shift = ((RubyFixnum)other).getLongValue();
    5
    shift = ((RubyFixnum)other).getLongValue();
    6
    if (shift < 0)
    6
    if (shift < 0)
    7
    neg = true;
    7
    neg = true;
    8
    shift = -shift;
    8
    shift = -shift;
    Precondition Violations (1)
    Row Violation
    1Clone fragment #1 returns variables shift, neg , while Clone fragment #2 returns variables shift, neg