Ruby runtime = context.getRuntime(); if (!block.isGiven()) return enumeratorize(runtime, this, "each"); if (begin instanceof RubyFixnum && end instanceof RubyFixnum) { fixnumEach(context, runtime, block); } else if (begin instanceof RubyString) { ((RubyString) begin).uptoCommon19(context, end, isExclusive, block); } else { if (!begin.respondsTo("succ")) throw getRuntime().newTypeError( "can't iterate from " + begin.getMetaClass().getName()); rangeEach(context, new RangeCallBack() { @Override void call(ThreadContext context, IRubyObject arg) { block.yield(context, arg); } }); } return this;
final Ruby runtime = context.getRuntime(); if (!block.isGiven()) return enumeratorize(runtime, this, "each"); if (begin instanceof RubyFixnum && end instanceof RubyFixnum) { fixnumEach(context, runtime, block); } else if (begin instanceof RubyString) { ((RubyString) begin).uptoCommon18(context, end, isExclusive, block); } else { if (!begin.respondsTo("succ")) throw getRuntime().newTypeError( "can't iterate from " + begin.getMetaClass().getName()); rangeEach(context, new RangeCallBack() { @Override void call(ThreadContext context, IRubyObject arg) { block.yield(context, arg); } }); } return this;
Clone fragments detected by clone detection tool
File path: /jruby-1.4.0/src/org/jruby/RubyRange.java File path: /jruby-1.4.0/src/org/jruby/RubyRange.java
Method name: IRubyObject each19(ThreadContext, Block) Method name: IRubyObject each(ThreadContext, Block)
Number of AST nodes: 11 Number of AST nodes: 11
1
Ruby runtime = context.getRuntime();
1
final Ruby runtime = context.getRuntime();
2
        if (!block.isGiven()) return enumeratorize(runtime, this, "each");
2
        if (!block.isGiven()) return enumeratorize(runtime, this, "each");
3
        if (begin instanceof RubyFixnum && end instanceof RubyFixnum) {
3
        if (begin instanceof RubyFixnum && end instanceof RubyFixnum) {
4
            fixnumEach(context, runtime, block);
4
            fixnumEach(context, runtime, block);
5
        } else if (begin instanceof RubyString) {
5
        } else if (begin instanceof RubyString) {
6
            ((RubyString) begin).uptoCommon19(context, end, isExclusive, block);
6
            ((RubyString) begin).uptoCommon18(context, end, isExclusive, block);
7
        } else {
7
        } else {
8
            if (!begin.respondsTo("succ")) throw getRuntime().newTypeError(
8
            if (!begin.respondsTo("succ")) throw getRuntime().newTypeError(
9
                    "can't iterate from " + begin.getMetaClass().getName());
9
                    "can't iterate from " + begin.getMetaClass().getName());
10
            rangeEach(context, new RangeCallBack() {
10
            rangeEach(context, new RangeCallBack() {
11
                @Override
11
                @Override
12
                void call(ThreadContext context, IRubyObject arg) {
12
                void call(ThreadContext context, IRubyObject arg) {
13
                    block.yield(context, arg);
13
                    block.yield(context, arg);
14
                }
14
                }
15
            });
15
            });
16
        }
16
        }
17
        return this;
17
        return this;
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.5
Clones locationClones are declared in the same class
Number of node comparisons44
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements10
    Number of unmapped statements in the first code fragment1
    Number of unmapped statements in the second code fragment1
    Time elapsed for statement mapping (ms)2.9
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
                                                                                          
    1
    final Ruby runtime = context.getRuntime();
    1
    Ruby runtime = context.getRuntime();
                                                                              
    2
    if (!block.isGiven())
    2
    if (!block.isGiven())
    3
    return enumeratorize(runtime, this, "each");
    3
    return enumeratorize(runtime, this, "each");
    4
    if (begin instanceof RubyFixnum && end instanceof RubyFixnum)
    4
    if (begin instanceof RubyFixnum && end instanceof RubyFixnum)
    5
    fixnumEach(context, runtime, block);
    5
    fixnumEach(context, runtime, block);
    6
    else if (begin instanceof RubyString)
    6
    else if (begin instanceof RubyString)
    7
    ((RubyString)begin).uptoCommon19(context, end, isExclusive, block);
    7
    ((RubyString)begin).uptoCommon19(context, end, isExclusive, block);
    7
    ((RubyString)begin).uptoCommon18(context, end, isExclusive, block);
    Differences
    Expression1Expression2Difference
    uptoCommon19uptoCommon18METHOD_INVOCATION_NAME_MISMATCH
    Preondition Violations
    Expression ((RubyString)begin).uptoCommon19(context,end,isExclusive,block) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression ((RubyString)begin).uptoCommon18(context,end,isExclusive,block) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    7
    ((RubyString)begin).uptoCommon18(context, end, isExclusive, block);
    else
    else
    8
    if (!begin.respondsTo("succ"))
    8
    if (!begin.respondsTo("succ"))
    9
    throw getRuntime().newTypeError("can't iterate from " + begin.getMetaClass().getName());
    9
    throw getRuntime().newTypeError("can't iterate from " + begin.getMetaClass().getName());
    10
    rangeEach(context, new RangeCallBack() {...});
    10
    rangeEach(context, new RangeCallBack() {...});
    11
    return this;
    11
    return this;
    Precondition Violations (2)
    Row Violation
    1Expression ((RubyString)begin).uptoCommon19(context,end,isExclusive,block) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    2Expression ((RubyString)begin).uptoCommon18(context,end,isExclusive,block) cannot be parameterized, because it has dependencies to/from statements that will be extracted