Ruby runtime = context.getRuntime(); IRubyObject i = from; RubyFixnum one = RubyFixnum.one(runtime); while (true) { if (i.callMethod(context, "<", to).isTrue()) { break; } block.yield(context, i); i = i.callMethod(context, "-", one); }
Ruby runtime = context.getRuntime(); IRubyObject i = from; RubyFixnum one = RubyFixnum.one(runtime); while (true) { if (i.callMethod(context, ">", to).isTrue()) { break; } block.yield(context, i); i = i.callMethod(context, "+", one); }
Clone fragments detected by clone detection tool
File path: /jruby-1.4.0/src/org/jruby/RubyInteger.java File path: /jruby-1.4.0/src/org/jruby/RubyInteger.java
Method name: void duckDownto(ThreadContext, IRubyObject, IRubyObject, Block) Method name: void duckUpto(ThreadContext, IRubyObject, IRubyObject, Block)
Number of AST nodes: 8 Number of AST nodes: 8
1
Ruby runtime = context.getRuntime();
1
Ruby runtime = context.getRuntime();
2
        IRubyObject i = from;
2
        IRubyObject i = from;
3
        RubyFixnum one = RubyFixnum.one(runtime);
3
        RubyFixnum one = RubyFixnum.one(runtime);
4
        while (true) {
4
        while (true) {
5
            if (i.callMethod(context, "&lt;", to).isTrue()) {
5
            if (i.callMethod(context, "&gt;", to).isTrue()) {
6
                break;
6
                break;
7
            }
7
            }
8
            block.yield(context, i);
8
            block.yield(context, i);
9
            i = i.callMethod(context, "-", one);
9
            i = i.callMethod(context, "+", one);
10
        }
10
        }
Summary
Number of common nesting structure subtrees1
Number of refactorable cases1
Number of non-refactorable cases0
Time elapsed for finding largest common nesting structure subtrees (ms)0.3
Clones locationClones are declared in the same class
Number of node comparisons22
  1. {Refactorable}
    Mapping Summary
    Number of mapped statements8
    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.4
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
    1
    Ruby runtime = context.getRuntime();
    1
    Ruby runtime = context.getRuntime();
    2
    IRubyObject i = from;
    2
    IRubyObject i = from;
    3
    RubyFixnum one = RubyFixnum.one(runtime);
    3
    RubyFixnum one = RubyFixnum.one(runtime);
    4
    while (true)
    4
    while (true)
    5
    if (i.callMethod(context, "<", to).isTrue())
    5
    if (i.callMethod(context, "<", to).isTrue())
    5
    if (i.callMethod(context, ">", to).isTrue())
    Differences
    Expression1Expression2Difference
    "<"">"LITERAL_VALUE_MISMATCH
    5
    if (i.callMethod(context, ">", to).isTrue())
    6
    break;
    6
    break;
    7
    block.yield(context, i);
    7
    block.yield(context, i);
    8
    i = i.callMethod(context, "-", one);
    8
    i = i.callMethod(context, "-", one);
    8
    i = i.callMethod(context, "+", one);
    Differences
    Expression1Expression2Difference
    "-""+"LITERAL_VALUE_MISMATCH
    8
    i = i.callMethod(context, "+", one);
    Precondition Violations (0)
    Row Violation